****************************************************************** * * * PROGRAM : SAPxSCx.SAS * * * * PROGRAMMER : Anne Maumary-Gremaud * * * * PURPOSE : Create a SAS dataset containing derived * * variables from the Pxaix datasets. * * Program can be modified to process Pxaix data * * from any cohort or year by setting severals * * parameters at beginning of program. * * * * MODIFIED: To change missing cutoff to 75% & set paths-- * * 07/16/03 Anne Corrigan * * * * * * INPUT : Datasets containing elemental SAS variables * * for each sites (xPxaix) * * * * OUPUT : SAS dataset containing the derived variables * * * ******************************************************************; **Enter year of data collection **; %let yr=11; /* Library location: */ libname data "d:/SASdata/SAP&yr.DataAll"; ** Fill out information in next section for data ** ** Processed in this run. Not used. **; ** Name lib Holding SAS data infiles **; /* libname SASIN 'j:/fastrack/projects/mdsctran/sas/raw' */ ** Specify Lib for output data sets. Not used. **; /* libname SASOUT 'j:/fastrack/tech_rpt/schladj/sas' */ ** Enter Cohort Number **; /* Not used. infile data set only contains cohort 1 */ /* %let coh= 1 ; */ **** DO NOT MODIFY BELLOW THIS LINE ****************************; data data.sap&yr.scored; set data.p&yr.ai_clean; ** recode 12 items for consistency of meaning items 8, 13, 14, 15, 17, 18, 19, 20, 22 and 25**; array X[10] p&yr.ai8 p&yr.ai13 p&yr.ai14 p&yr.ai15 p&yr.ai17 p&yr.ai18 p&yr.ai19 p&yr.ai20 p&yr.ai22 p&yr.ai25; array RX[10] rp&yr.ai8 rp&yr.ai13 rp&yr.ai14 rp&yr.ai15 rp&yr.ai17 rp&yr.ai18 rp&yr.ai19 rp&yr.ai20 rp&yr.ai22 rp&yr.ai25; do i=1 to 10; RX[i]=6-X[i]; end; drop i; ** Handling missing values **; count1=0; count2=0; array contact[*] p&yr.ai23 p&yr.ai24 ; array tot[*] rp&yr.ai8 p&yr.ai9 p&yr.ai10 p&yr.ai11 p&yr.ai12 rp&yr.ai13 rp&yr.ai14 rp&yr.ai15 p&yr.ai16 rp&yr.ai17 rp&yr.ai18 rp&yr.ai19 rp&yr.ai20 p&yr.ai21 rp&yr.ai22 rp&yr.ai25; sum1=sum(of contact[*]); sum2=sum(of tot[*]); /*get a count of missing for contact[] */ do i=1 to 2; if contact[i] = . then count1 = count1 + 1; end; drop i; /* where less than 75% are missing, fill in missing values with mean. */ /* note: original scoring program used le, not lt. This is preserved. */ do i=1 to 2; if count1 le .5 then if contact[i] =. then contact[i]=sum1/(2-count1); end; drop i; /* get a count of missing for tot[] */ do i=1 to 16; if tot[i]=. then count2=count2+1; end; drop i; /* where less than 75% are missing, fill in missing values with mean. */ do i=1 to 16; if count2 le 4 then if tot[i]=. then tot[i]=sum2/(16-count2); end; drop i; ** Computes the scales **; sap&yr.con=(p&yr.ai23+p&yr.ai24)/2; sap&yr.tot=(rp&yr.ai8+p&yr.ai9+p&yr.ai10+p&yr.ai11+p&yr.ai12+rp&yr.ai13+rp&yr.ai14+rp&yr.ai15+ p&yr.ai16+rp&yr.ai17+rp&yr.ai18+rp&yr.ai19+rp&yr.ai20+p&yr.ai21+rp&yr.ai22 +rp&yr.ai25)/16; label sap&yr.con="School adj parent: contact w school Yr &yr." sap&yr.tot="School adj parent:total Yr &yr."; keep site tcid cohort treatmnt norm sap&yr.con sap&yr.tot p&yr.ai6-p&yr.ai25 rp&yr.ai8 rp&yr.ai13 rp&yr.ai14 rp&yr.ai15 rp&yr.ai17 rp&yr.ai18 rp&yr.ai19 rp&yr.ai20 rp&yr.ai22 rp&yr.ai25 p&yr.ai26; run; proc contents; run;