/****************************************************** * This program reads in a:\srcddata.dat and * * writes out data sets in various formats to a: drive * ******************************************************/ filename srcddata 'a:\srcddata.dat'; filename srcdfull 'a:\srcdfull.dat'; filename srcdmiss 'a:\srcdmiss.dat'; filename fulllev1 'a:\fulllev1.dat'; filename fulllev2 'a:\fulllev2.dat'; filename misslev1 'a:\misslev1.dat'; filename misslev2 'a:\misslev2.dat'; options nocenter linesize=80; data srcd; infile srcddata; ** Inputting data in free format -- missing data denoted by 999; input anti1 anti2 anti3 anti4 read1 read2 read3 read4 gen momage kidage homecog homeemo id; ** Computing Time variable for possible use in HLM analysis; time1=0; time2=1; time3=2; time4=3; ** Setting values of 999 for anti & read; ** to system missing for SAS computations; array x{8} anti1--read4; do i=1 to 8; if x{i}=999 then x{i}=.; end; run; /************************************************************* * Creating SAS internal dataset named NOMISS that contains * * only cases with complete data on all measures * * at all time points -- Results in N=221 * *************************************************************/ data nomiss; set srcd; if nmiss(of gen momage kidage homecog homeemo anti1-anti4 read1-read4)=0; run; /************************************************************ * Creating SAS internal dataset named MISS that contains * * cases with complete data on only Time 1 measures * * and partially missing thereafter: Results in N=405 * ************************************************************/ data miss; set srcd; if nmiss(of gen momage kidage homecog homeemo anti1 read1)=0; run; /***************************************************************** * Some basic descriptive statistics on data sets NOMISS and MISS * *****************************************************************/ proc freq data=nomiss; Title 'Frequencies for complete data set: N=221'; tables gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; proc freq data=miss; Title 'Frequencies for partially complete data set: N=405'; tables gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; proc means data=nomiss; Title 'Means for complete data set: N=221'; var gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; proc means data=miss; Title 'Means for partially complete data set: N=405'; var gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; proc sort data=nomiss; by gen; run; proc sort data=miss; by gen; run; proc means data=nomiss; Title 'Means for complete data set conditioned on gender: N=221'; Title2 'Female=0, Male=1'; var momage kidage homecog homeemo anti1-anti4 read1-read4; by gen; run; proc means data=miss; Title 'Means for partially complete data set conditioned on gender: N=405'; Title2 'Female=0, Male=1'; var momage kidage homecog homeemo anti1-anti4 read1-read4; by gen; run; proc corr data=nomiss; Title 'Correlations for complete data set: N=221'; Title2 ' '; var gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; proc corr data=miss; Title 'Correlations for partially complete data set: N=405'; var gen momage kidage homecog homeemo anti1-anti4 read1-read4; run; /*********************************************** * The following lines read out the complete * * and missing data sets in various formats for * * potential input into other software packages * ***********************************************/ proc sort data=nomiss; by id; run; proc sort data=miss; by id; run; /***************************************************** * Reading NOMISS to outfile SRCDFULL, * * N=221 cases, 1 record per case, 221 total records * *****************************************************/ data _null_; set nomiss; file srcdfull; put #1 (anti1-anti4 read1-read4 gen momage kidage homecog homeemo id) (13*f8.2,f6.0); run; /****************************************************** * Reading MISS to outfile SRCDMISS, * * N=405 cases, 1 record per case, 405 total records * ******************************************************/ data _null_; set miss; file srcdmiss; ** Recoding missing values to 999 for potential input into HLM program; array x{8} anti1--read4; do i=1 to 8; if x{i}=. then x{i}=999; end; put #1 (anti1-anti4 read1-read4 gen momage kidage homecog homeemo id) (13*f8.2,f6.0); run; /****************************************************************** * Reading NOMISS to outfile FULLLEV1 for Level 1 HLM data file, * * N=221 cases, 4 records per case, 884 total records * ******************************************************************/ data _null_; set nomiss; file fulllev1; put #1 (id time1 anti1 read1) (f6.0,3*8.2); put #2 (id time2 anti2 read2) (f6.0,3*8.2); put #3 (id time3 anti3 read3) (f6.0,3*8.2); put #4 (id time4 anti4 read4) (f6.0,3*8.2); run; /****************************************************************** * Reading NOMISS to outfile FULLLEV2 for Level 2 HLM data file, * * N=221 cases, 1 record per case, 221 total records * ******************************************************************/ data _null_; set nomiss; file fulllev2; put #1 (id gen momage kidage homecog homeemo) (f6.0,5*f8.2); run; /***************************************************************** * Reading MISS to outfile MISSLEV1 for Level 1 HLM data file, * * N=405 cases, 4 records per case, 1620 total records * *****************************************************************/ data _null_; set miss; file misslev1; ** Recoding missing values to 999 for potential input into HLM program; array x{8} anti1--read4; do i=1 to 8; if x{i}=. then x{i}=999; end; put #1 (id time1 anti1 read1) (f6.0,3*f8.2); put #2 (id time2 anti2 read2) (f6.0,3*f8.2); put #3 (id time3 anti3 read3) (f6.0,3*f8.2); put #4 (id time4 anti4 read4) (f6.0,3*f8.2); run; /*************************************************************** * Reading MISS to outfile FULLLEV2 for Level 2 HLM data file * * N=405 cases, 1 record per case, 405 total records * ***************************************************************/ data _null_; set miss; file misslev2; ** Recoding missing values to 999 for potential input into HLM program; array x{8} anti1--read4; do i=1 to 8; if x{i}=. then x{i}=999; end; put #1 (id gen momage kidage homecog homeemo) (f6.0,5*f8.2); run;