************************************************************** * * * PROGRAM: PML * * * * PROGRAMMER: Mary Gifford-Smith * * * * PURPOSE: Create a SAS data set containing derived * * variables from the CxR data sets (People * * in My Life). Program can be modified to * * process CxR data from any cohorts, beginning * * in Year 5 (first year measure was given) * * by setting several parameters at beginning * * of program. * * * * MODIFIED: To run from aggregated datasets - Patrick * * Malone 11/9/01 * * * * INPUT: Datasets containing elemental SAS variables * * (CxR). * * * * OUTPUT: SAS dataset containing the derived variables.* * * **************************************************************; **Fill out information in next section for data processed ** **in this run. **; %let source=Child; %let src=c; %let inst=r; %let longname=peopleinmylife; %let scoredname=PML; **Enter high-level path (e.g., l:\datasets) **; %let path=d:/datasets; **Enter year of data collection **; %let yr=6; **Enter variable which must be present to retain record (typically interviewer id) **; %let screen=intid; **Specify Lib for input datasets **; Libname SASIN "&path.\&source.\&longname.\U"; **Specify Lib for output datasets **; Libname SASOUT "&path.\&source.\&longname.\S"; ****** DO NOT MODIFY BELOW THIS LINE **************; data SASOUT.&scoredname.&yr.; set SASIN.&src.&yr.&inst; if &screen ne ''; **Reverse scoring items for consistency**; if C&yr.RP10=1 then C&yr.RP10R=4; if C&yr.RP10=2 then C&yr.RP10R=3; if C&yr.RP10=3 then C&yr.RP10R=2; if C&yr.RP10=4 then C&yr.RP10R=1; if C&yr.RP11=1 then C&yr.RP11R=4; if C&yr.RP11=2 then C&yr.RP11R=3; if C&yr.RP11=3 then C&yr.RP11R=2; if C&yr.RP11=4 then C&yr.RP11R=1; if C&yr.RP12=1 then C&yr.RP12R=4; if C&yr.RP12=2 then C&yr.RP12R=3; if C&yr.RP12=3 then C&yr.RP12R=2; if C&yr.RP12=4 then C&yr.RP12R=1; if C&yr.RP13=1 then C&yr.RP13R=4; if C&yr.RP13=2 then C&yr.RP13R=3; if C&yr.RP13=3 then C&yr.RP13R=2; if C&yr.RP13=4 then C&yr.RP13R=1; if C&yr.RP14=1 then C&yr.RP14R=4; if C&yr.RP14=2 then C&yr.RP14R=3; if C&yr.RP14=3 then C&yr.RP14R=2; if C&yr.RP14=4 then C&yr.RP14R=1; if C&yr.RF10=1 then C&yr.RF10R=4; if C&yr.RF10=2 then C&yr.RF10R=3; if C&yr.RF10=3 then C&yr.RF10R=2; if C&yr.RF10=4 then C&yr.RF10R=1; if C&yr.RF11=1 then C&yr.RF11R=4; if C&yr.RF11=2 then C&yr.RF11R=3; if C&yr.RF11=3 then C&yr.RF11R=2; if C&yr.RF11=4 then C&yr.RF11R=1; if C&yr.RF12=1 then C&yr.RF12R=4; if C&yr.RF12=2 then C&yr.RF12R=3; if C&yr.RF12=3 then C&yr.RF12R=2; if C&yr.RF12=4 then C&yr.RF12R=1; if C&yr.RF13=1 then C&yr.RF13R=4; if C&yr.RF13=2 then C&yr.RF13R=3; if C&yr.RF13=3 then C&yr.RF13R=2; if C&yr.RF13=4 then C&yr.RF13R=1; if C&yr.RF14=1 then C&yr.RF14R=4; if C&yr.RF14=2 then C&yr.RF14R=3; if C&yr.RF14=3 then C&yr.RF14R=2; if C&yr.RF14=4 then C&yr.RF14R=1; label C&yr.RP10R="parents don't understand, recoded"; label C&yr.RP11R="upset with parents, recoded"; label C&yr.RP12R="angry with parents, recoded"; label C&yr.RP13R="hard to talk to parents, recoded"; label C&yr.RP14R="scared in my home, recoded"; label C&yr.RF10R="friends don't understand, recoded"; label C&yr.RF11R="upset with friends, recoded"; label C&yr.RF12R="angry with friends, recoded"; label C&yr.RF13R="scared with my friends, recoded"; label C&yr.RF14R="hard to talk to friends, recoded"; **compute the derived variable of attachment to parent**; **Dealing with missing values**; array A[15] C&yr.RP1 C&yr.RP2 C&yr.RP3 C&yr.RP4 C&yr.RP5 C&yr.RP6 C&yr.RP7 C&yr.RP8 C&yr.RP9 C&yr.RP10R C&yr.RP11R C&yr.RP12R C&yr.RP13R C&yr.RP14R C&yr.RP15; count1=0; sum1=sum(of A[*]); do i=1 to 15; if A[i]=' ' then count1=count1+1; end; drop i; do i=1 to 15; if count1 le 7 then if A[i]=" " then A[i]=sum1/(15-count1); end; drop i; PML&yr.PATT=(C&yr.RP1+C&yr.RP2+C&yr.RP3+C&yr.RP4+C&yr.RP5+C&yr.RP6+C&yr.RP7+ C&yr.RP8+C&yr.RP9+C&yr.RP10R+C&yr.RP11R+C&yr.RP12R+C&yr.RP13R+C&yr.RP14R+ C&yr.RP15)/15; label PML&yr.PATT='Quality of attachment to parent'; **compute the derived variable of attachment to friends**; **Dealing with missing values**; array B[15] C&yr.RF1 C&yr.RF2 C&yr.RF3 C&yr.RF4 C&yr.RF5 C&yr.RF6 C&yr.RF7 C&yr.RF8 C&yr.RF9 C&yr.RF10R C&yr.RF11R C&yr.RF12R C&yr.RF13R C&yr.RF14R C&yr.RF15; count2=0; sum2=sum(of B[*]); do i=1 to 15; if B[i]=' ' then count2=count2+1; end; drop i; do i=1 to 15; if count2 le 7 then if B[i]=" " then B[i]=sum2/(15-count1); end; drop i; PML&yr.FATT=(C&yr.RF1+C&yr.RF2+C&yr.RF3+C&yr.RF4+C&yr.RF5+C&yr.RF6+C&yr.RF7+ C&yr.RF8+C&yr.RF9+C&yr.RF10R+C&yr.RF11R+C&yr.RF12R+C&yr.RF13R+C&yr.RF14R+ C&yr.RF15)/15; label PML&yr.FATT='Quality of attachment to friends'; **compute the derived variable positive representations of parents**; **dealing with missing values**; array C[10] C&yr.RP1 C&yr.RP2 C&yr.RP3 C&yr.RP4 C&yr.RP5 C&yr.RP6 C&yr.RP7 C&yr.RP8 C&yr.RP9 C&yr.RP15; count3=0; sum3=sum(of C[*]); do i=1 to 10; if C[i]=" " then count3=count3+1; end; drop i; do i=1 to 10; if count3 le 5 then if C[i]=" " then C[i]=sum3/(10-count3); end; drop i; PML&yr.POSP=(C&yr.RP1+C&yr.RP2+C&yr.RP3+C&yr.RP4+C&yr.RP5+C&yr.RP6+C&yr.RP7+ C&yr.RP8+C&yr.RP9+C&yr.RP15)/10; label PML&yr.POSP="positive representations of parents"; **compute the derived variable: positive representations of peers**; **dealing with missing data**; array D[10] C&yr.RF1 C&yr.RF2 C&yr.RF3 C&yr.RF4 C&yr.RF5 C&yr.RF6 C&yr.RF7 C&yr.RF8 C&yr.RF9 C&yr.RF15; count4=0; sum4=sum(of D[*]); do i=1 to 10; if D[i]=" " then count4=count4+1; end; drop i; do i=1 to 10; if count4 le 5 then if D[i]=" " then D[i]=sum4/(10-count4); end; drop i; PML&yr.POSF=(C&yr.RF1+C&yr.RF2+C&yr.RF3+C&yr.RF4+C&yr.RF5+C&yr.RF6+C&yr.RF7+ C&yr.RF8+C&yr.RF9+C&yr.RF15)/10; label PML&yr.POSF="positive representations of friends"; **compute derived variable: negative representations of significant others"**; **dealing with missing data**; array E[10]C&yr.RP10 C&yr.RP11 C&yr.RP12 C&yr.RP13 C&yr.RP14 C&yr.RF10 C&yr.RF11 C&yr.RF12 C&yr.RF13 C&yr.RF14; count5=0; sum5=sum(of E[*]); do i=1 to 10; if E[i]=" " then count5=count5+1; end; drop i; do i=1 to 10; if count5 le 5 then if E[i]=" " then E[i]=sum5/(10-count5); end; drop i; PML&yr.NEGO=(C&yr.RP10+C&yr.RP11+C&yr.RP12+C&yr.RP13+C&yr.RP14+C&yr.RF10+ C&yr.RF11+C&yr.RF12+C&yr.RF13+C&yr.RF14)/10; label PML&yr.NEGO="negative representations of significant others"; drop count1-count5 sum1-sum5 year; output; run;