****************************************************************** * * * PROGRAM : PIR7SP1.sas * * * * PROGRAMMER : Anne Maumary-Gremaud * * * * PURPOSE : Create a SAS dataset containing derived * * variables from the PxTx datasets. * * Program can be modified to process PxTx data * * from any cohort or year by setting severals * * parameters at beginning of program. * * * * INPUT : Datasets containing elemental SAS variables * * for each sites (xPxTx) * * * * OUPUT : SAS dataset containing the derived variables * * * ******************************************************************; ** Fill out information in next section for data ** ** Processed in this run. **; ** Name lib Holding SAS data infiles **; libname SASIN 'c:/mydocuments/anne/score_ft' ; ** Name lib holding SAS data for allkey file **; libname k 'c:/mydocuments/anne/fastrack'; ** Specify Lib for output data sets **; libname SASOUT 'c:/mydocuments/anne/score_ft/to-ftp' ; ** Enter Cohort Number **; %let coh=1 ; ** Enter year of data collection **; %let yr=7 ; **** DO NOT MODIFY BELLOW THIS LINE ****************************; data temp; set SASIN.DP&yr.T&coh. SASIN.NP&yr.T&coh. SASIN.PP&yr.T&coh. SASIN.SP&yr.T&coh. ; ** Handling missing values **; data first; set temp; count1=0; count2=0; array child[*] P&yr.TCH2 P&yr.TCH3 P&yr.TCH4 P&yr.TCH7 P&yr.TCH8 P&yr.TCH9 ; array parent[*] P&yr.TPA1 P&yr.TPA2 P&yr.TPA3 P&yr.TPA4 P&yr.TPA5 P&yr.TPA6 P&yr.TPA7 P&yr.TPA8 P&yr.TPA9 P&yr.TPA10 P&yr.TPA11 ; sum1=sum(of child[*]); sum2=sum(of parent[*]); do i=1 to 6; if child[i] = . then count1 = count1 + 1; end; drop i; do i=1 to 6; if count1 le 3 then if child[i] =. then child[i]=sum1/(6-count1); end; drop i; do i=1 to 11; if parent[i]=. then count2=count2+1; end; drop i; do i=1 to 11; if count2 le 5 then if parent[i]=. then parent[i]=sum2/(11-count2); end; drop i; ** Creating the scales **; PIR&YR.CHC=(P&yr.TCH2+P&yr.TCH3+P&yr.TCH4+P&yr.TCH7+P&yr.TCH8+P&yr.TCH9)/6; PIR&YR.CHP=(P&yr.TPA1+P&yr.TPA2+P&yr.TPA3+P&yr.TPA4+P&yr.TPA5+P&yr.TPA6+P&yr.TPA7+P&yr.TPA8+P&yr.TPA9 +P&yr.TPA10+P&yr.TPA11)/11; label PIR&YR.CHC="PIR_ Rating of Change of Child YR &Yr." PIR&YR.CHP="PIR_ Rating of Change of Parent YR &yr."; ** Merging with the allkey file keeping only the subjects in both **; proc sort; by site cohort tcid; run; data keys; set k.allkey6; where cohort="&coh."; proc sort; by site cohort tcid; run; data second ; merge first(in=a) keys(in=b); by site cohort tcid; if a=1 and b=1; run; ** Setting the permanent SAS dataset **; data SASOUT.PIR&yr.SP&coh. (LABEL = "Scored Parent Post Inter Ratings Y&yr. c&coh.") ; set second; keep cohort site tcid PIR&YR.CHC PIR&YR.CHP; run; PROC CONTENTS; RUN; proc print; run;