************************************************************ * PROGRAM: PCF9.SAS * * PROGRAMMER: Cindy Rains * * DATE: 3/26/03 * * * * PURPOSE: This program creates three scales and one * * dataset w/ all of the data for public use. * * * INPUT: PxO, s=site, y=year, c=cohort * * * * OUTPUT: PCF9SP1 * ************************************************************; ** Fill out information below for data processed in this run **; ** Name library holding SAS input data files **; LIBNAME SASIN "l:/datasets/parent/parentreportfriend/u" ; ** Specify cohort number **; %let coh = 1 ; ** Enter year of data collection **; %let yr = 9 ; /* Grade 8 */ *************** DO NOT MODIFY BELOW THIS LINE ******************************; ** Specify library for output datasets **; LIBNAME SASOUT "d:\work\childs friends\year 9" ; ** Allkey datasets **; LIBNAME ALL "d:\allkey" ; options ps=80 ls=132 nocenter nostimer ; *****************************************************************************; ** The macro, "linsum" creates derived variables which are means of input ** ** scale items. In the case of missing input items, the output variable ** ** is defined to be missing if half or more of the input items are ** ** missing. Otherwise, missing input items are replaced with the mean of ** ** the nonmissing items. The macro call to linsum specifies the input ** ** items as a string "var_list" of variable names, and specifies the ** ** label and name of the output variable as "var_name" and "var_labl" ** ** respectively. **; %macro linsum ; data first ; set &INDATA ; count = 0 ; label &var_name = "&var_labl" ; meanz = 0 ; array sumvars &var_list ; array working &var_list count meanz &var_name ; do i = 1 to dim(sumvars) ; if working(i) = . then count = count + 1 ; end ; do i = 1 to 1 ; meanz = mean(of &var_list) ; end ; do i = 1 to dim(sumvars) ; if working(i) = . then working(i) = meanz ; end ; do i = 1 to 1 ; if count le .5*dim(sumvars) then &var_name = sum(of &var_list) ; else &var_name = . ; end ; keep site tcid &var_name ; proc sort ; by site tcid ; data &INDATA ; merge first &INDATA ; by site tcid ; %mend linsum; *****************************************************************************; DATA PCF1 ; SET SASIN.p9o ; * reverse score ; * higher score equals greater concern about child's friends; ARRAY P&yr.O {9} P&yr.O1-P&yr.O9; ARRAY RP&yr.O {9} RP&yr.O1-RP&yr.O9; DO I=1 TO 9; IF P&yr.O{I} = 1 THEN RP&yr.O{I} = 4; ELSE IF P&yr.O{I} = 2 THEN RP&yr.O{I} = 3; ELSE IF P&yr.O{I} = 3 THEN RP&yr.O{I} = 2; ELSE IF P&yr.O{I} = 4 THEN RP&yr.O{I} = 1; ELSE RP&yr.O{I}=P&yr.O{I}; P&yr.O{I}=RP&yr.O{I}; END; DROP RP&yr.O1-RP&yr.O9; /* if P&yr.O10=1 then P&yr.O10r=5; if P&yr.O10=2 then P&yr.O10r=4; if P&yr.O10=3 then P&yr.O10r=3; if P&yr.O10=4 then P&yr.O10r=2; if P&yr.O10=5 then P&yr.O10r=1;*/ P&yr.O10x=((P&yr.O10-1)*3/4)+1; DATA PCF2 ; MERGE PCF1 (IN=PCF) ALL.ALLKEY&coh. (IN=ALL) ; BY SITE TCID ; IF PCF AND ALL ; /* Specify definitions for SCALE VARIABLES below: ** */ %let INDATA = PCF2 ; ************************************************************; %let var_name = PCF&yr.TRO ; %let var_labl = %str(Trouble with Adults - Close Friends ) ; %let var_list = %str(P&yr.O1 P&yr.O4 P&yr.O7 ) ; %linsum ; ************************************************************; %let var_name = PCF&yr.PDA ; %let var_labl = %str(Parental Disapproval - Close Friends) ; %let var_list = %str(P&yr.O2 P&yr.O5 P&yr.O8 ) ; %linsum ; ************************************************************; %let var_name = PCF&yr.NIN ; %let var_labl = %str(Negative Influence - Close Friends) ; %let var_list = %str(P&yr.O3 P&yr.O6 P&yr.O9 ); %linsum ; ************************************************************; %let var_name = PCF&yr.TPC ; %let var_labl = %str(Total Parental Concern - Close Friends) ; %let var_list = %str(P&yr.O1 P&yr.O2 P&yr.O3 P&yr.O4 P&yr.O5 P&yr.O6 P&yr.O7 P&yr.O8 P&yr.O9 P&yr.O10rx); %linsum ; ************************************************************; DATA SASOUT.PCF&yr.SP&coh. (label="Scored Parent Report on Child's Close Friends Y&yr. C&coh.") ; SET PCF2; **This keeps all of the data from the original dataset, PxO, and creates a scored dataset**; Keep site tcid cohort intid respond sitecode P&YR.O1-P&YR.O10 P&YR.O10x PCF&YR.TRO PCF&YR.PDA PCF&YR.NIN PCF&YR.TPC; LABEL P&yr.O1="Does Best Friend Get into Trouble w/Police, etc?-reversed" P&yr.O2="Does Best Friend Do Things You Disapprove of? -reversed" P&yr.O3="Concerned about Negative Influence of Best Friend?-reversed " P&yr.O4="Does 2nd Best Friend Get into Trouble w/Police, etc?-reversed" P&yr.O5="Does 2nd Best Friend Do Things You Disapprove of? -reversed" P&yr.O6="Concerned about Negative Influence of 2nd Best Friend?-reversed" P&yr.O7="Do Close Friends Get into Trouble w/Police, etc?-reversed" P&yr.O8="Do Close Friends Do Things You Disapprove of? -reversed" P&yr.O9="Concerned about Negative Influence of Close Friends?-reversed" P&yr.O10="Amount of Time TC Spends w/Friends in Trouble" P&yr.O10x="Amount of Time TC Spends w/Friends in Trouble" PCF&yr.PDA="Parental Disapproval of Friends" PCF&yr.NIN="Parental Concern over Negative Influence of Friends"; run; proc contents; run ; proc freq; table P&YR.O1 P&YR.O10x PCF&YR.TRO PCF&YR.PDA PCF&YR.NIN PCF&YR.TPC; run;