AS/IML program using the RII technique for scalar values

SAS/IML program using the RII technique for scalar values


/*Use Courier 10 point font to maintain document set up.
This program was written by Jaimie Sung and Catherine P. Montalto, Consumer
and Textile Sciences Department, The Ohio State University.  The program is
written in SAS/IML matrix language and uses the repeated-imputation
inference (RII) technique to derive estimates of the mean and the standard
error of the mean for variables in the 1992 Survey of Consumer Finances. 
The RII technique incorporates the variability in the data due to missing
data into the estimate of the standard error of the mean.  Equation numbers
correspond to Appendix A in Montalto & Sung (1996), Multiple imputation in
the 1992 Survey of Consumer Finances, Financial Counseling and Planning,
Vol. 7, pp. 133-146.

The computer code is provided as a service.  Users should familiarize
themselves with the RII technique and SAS/IML to insure appropriate and
accurate use and interpretation of the program and program output.  Users
will need to insert the appropriate job control language and data creation
commands at the beginning of the program.  X1, X2, X3 and X4 are used in
the code to refer to variables.  Users should edit the number of Xi
variables as appropriate and define these variables in the program.
*/

IMP=Y1-INT(Y1/10)*10;
X1={variable_name};  X2={variable_name};
X3={variable_name};  X4={variable_name);
PROC SORT; BY IMP;
PROC UNIVARIATE VARDEF=WDF;
  VAR X1 X2 X3 X4;
  WEIGHT X42000;
  BY IMP;
  OUTPUT OUT=RII MEAN=QX1 QX2 QX3 QX4
                 STDMEAN=UX1 UX2 UX3 UX4;
PROC PRINT DATA=RII;

*RII TECHNIQUE FOR A SCALAR;
PROC IML;
  RESET AUTONAME;
  USE RII VAR{QX1 QX2 QX3 QX4}; READ ALL INTO QI;
  USE RII VAR{UX1 UX2 UX3 UX4}; READ ALL INTO UI;
  MM= NROW(QI); JMAT = J(MM,1);
  NN= NCOL(QI); NAMES={X1 X2 X3 X4};
*AVERAGE OF THE FIVE POINT ESTIMATES OF THE MEAN (Eq. 1);
  QMBAR=QI(|+,|)/MM;
*VARIANCE OF THE MEAN (SQUARE OF THE STANDARD ERROR);
  UI=UI#UI;
*AVERAGE WITHIN IMPUTATION VARIANCE (Eq. 2);
  UMBAR=UI(|+,|)/MM;
*INTERMEDIATE STEPS FOR CALCULATING BETWEEN IMPUTATION VARIANCE;
  QMBARX=QMBAR@JMAT;
  QDIF = QI-QMBARX;
  QDIFSQ = QDIF#QDIF;
*BETWEEN IMPUTATION VARIANCE (Eq. 3);
  BM = QDIFSQ(|+,|)/(MM-1);
*RII TOTAL VARIANCE OF THE MEAN (Eq. 4);
  TM = UMBAR+(1+1/MM)*BM;
*RII STANDARD ERROR OF THE MEAN (Eq. 5);
  SDTM = SQRT(TM);
*RELATIVE INCREASE IN VARIANCE DUE TO NONRESPONSE (Eq. 8);
  RM = (1+1/MM)*BM/UMBAR;
*DEGREES OF FREEDOM (Eq. 7);
  VUI = (MM-1)*(1+1/RM)##2;
*FRACTION OF INFORMATION ABOUT PARAMETER Q WHICH IS MISSING (Eq. 9);
  GAMMA =(RM+2/(VUI+3))/(RM+1);
*COMMANDS TO PRINT RESULTS;
PRINT, "RII TECHNIQUE FOR SCALAR Q";
PRINT, "EACH ROW C.T. EACH IMPUTATION"; 
PRINT, "COL.1 X1";
PRINT, "COL.2 X2";
PRINT, "COL.3 X3";
PRINT, "COL.4 X4";
PRINT QI;
PRINT QMBAR;
PRINT UI;
PRINT UMBAR;
PRINT BM;
PRINT TM;
PRINT SDTM;
PRINT RM;
PRINT VUI;
PRINT GAMMA;
/*   

Updated Nov. 22, 1996 by Catherine Montalto