******************************************************************* * * * PROGRAM : SAC.SAS * * * * PROGRAMMER : Anne Maumary-Gremaud * * * * PURPOSE : Create a SAS dataset containing derived * * variables from the CxY datasets. * * Program can be modified to process CxYx data * * from any year by setting severals * * parameters at beginning of program. * * * * MODIFIED: To work from aggregated datasets -- 11/12/01 * * Patrick Malone * * To change missing cutoff to 75% & set paths-- * * 07/15/03 Anne Corrigan * * * * INPUT : Datasets containing elemental SAS variables * * (CxY) * * * * OUPUT : SAS dataset containing the derived variables * * * ******************************************************************; **Enter year of data collection **; %let yr=11; **Fill out information in next section for data processed ** **in this run. **; %let src=c; %let inst=y; %let scoredname=SAC; **Enter high-level path (e.g., l:\datasets) **; %let path=D:\sasdata\sac&yr.DataAll; **Specify Lib for input datasets **; Libname data "&path."; **Specify Lib for output datasets **; Libname data "&path."; ****** DO NOT MODIFY BELOW THIS LINE **************; data data.&scoredname.&yr.scored; set data.&src.&yr.&inst._clean; ** recode 12 items for consistency of meaning **; array X[12] c&yr.ay7 c&yr.ay10 c&yr.ay13 c&yr.ay14 c&yr.ay15 c&yr.ay16 c&yr.ay18 c&yr.ay19 c&yr.ay20 c&yr.ay21 c&yr.ay23 c&yr.ay25; array RX[12] rc&yr.ay7 rc&yr.ay10 rc&yr.ay13 rc&yr.ay14 rc&yr.ay15 rc&yr.ay16 rc&yr.ay18 rc&yr.ay19 rc&yr.ay20 rc&yr.ay21 rc&yr.ay23 rc&yr.ay25; do i=1 to 12; RX[i]=6-X[i]; end; ** Handling missing values **; count1=0; count2=0; count3=0; /* Item 22=previous item 16 not used */ array friend[*] c&yr.ay9 rc&yr.ay10 rc&yr.ay14 rc&yr.ay15 rc&yr.ay19 rc&yr.ay20; array diff[*] rc&yr.ay7 c&yr.ay8 c&yr.ay11 rc&yr.ay13 rc&yr.ay16 rc&yr.ay18 rc&yr.ay21 rc&yr.ay25; array gen[*] c&yr.ay12 c&yr.ay17 rc&yr.ay23 c&yr.ay24 c&yr.ay26; /*Sum items in each subscale */ sum1=sum(of friend[*]); sum2=sum(of diff[*]); sum3=sum(of gen[*]); /*Get a count of missing for friend[] */ do i=1 to 6; if friend[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. AMC */ do i=1 to 6; if count1 le 1.5 then if friend[i] =. then friend[i]=sum1/(6-count1); end; drop i; /* Get a count of missing for diff[] */ do i=1 to 8; if diff[i]=. then count2=count2+1; end; drop i; /* Where less than 75% are missing, fill in missing values with mean. */ do i=1 to 8; if count2 le 2 then if diff[i]=. then diff[i]=sum2/(8-count2); end; drop i; /* Get a count of missing for gen[] */ do i=1 to 5; if gen[i]=. then count3=count3+1; end; drop i; /* Where less than 75% are missing, fill in missing values with mean. */ do i=1 to 5; if count3 le 1.25 then if gen[i]=. then gen[i]=sum3/(5-count3); end; drop i; ** Computes the scales **; sac&yr.frd=(c&yr.ay9+rc&yr.ay10+rc&yr.ay14+rc&yr.ay15+rc&yr.ay19+rc&yr.ay20)/6; sac&yr.dif=(rc&yr.ay7+c&yr.ay8+c&yr.ay11+rc&yr.ay13+rc&yr.ay16+rc&yr.ay18+ rc&yr.ay21+rc&yr.ay25)/8; sac&yr.gen=(c&yr.ay12+c&yr.ay17+rc&yr.ay23+c&yr.ay24+c&yr.ay26)/5; /*Data Notes: If a kid is not in school, item 30 will have a value of 1 to 19. Test on item 30 */ /* instead of item 28 because item 28 - Did you quit? - could be zero, /* and the kid was expelled, or was out sick. Quit seems to be taken literally. */ /* A .D in item 28 is a missing. */ label sac&yr.frd="School adj child: Friends Problems Yr &yr." sac&yr.dif="School adj child: Acad. and Discip. Difficulties Yr &yr." sac&yr.gen="School adj child: General Aspects Yr &yr."; footnote1 "Reasons for leaving school 1-Received degree or finished course work"; footnote2 "2-Expelled/suspended 3-Got married 4-Pregnant 5-School too dangerous"; footnote3 "6-Poor grades 7-Did not like school 8-Offered job 9-Entered military"; footnote4 "10-Financial problems 11-Child care 12-Home responsibilities 13-Moved away"; footnote5 "14-Did not get along with other students 15-Friends dropped out"; footnote6 "16-Problem with drugs or alcohol 17-Became a father or mother"; footnote7 "18-Health problems 19-Other"; footnote8 "Type of school 1-Public 2-Technical or vocational HS 3-Private religious 4-Private nonreligious 5-Alternative school 6-Other"; footnote9 "Grades 8-As 7-Half As, half Bs 6-Bs 5-Half Bs, half Cs 4-Cs 3-Half Cs, half Ds 2-Ds 1-Under Ds 9-Other"; keep tcid site cohort treatmnt norm sac&yr.frd sac&yr.dif sac&yr.gen c&yr.ay5-c&yr.ay49 rc&yr.ay7 rc&yr.ay10 rc&yr.ay13 rc&yr.ay14 rc&yr.ay15 rc&yr.ay16 rc&yr.ay18 rc&yr.ay19 rc&yr.ay20 rc&yr.ay21 rc&yr.ay23 rc&yr.ay25; run;