************************************************************ * PROGRAM: SCM3.SAS * * PROGRAMMER: Cindy Rains * * DATE: 3/05/03 * * * * PURPOSE: CxE datasets contain sociometric form data.* * This program creates a subscale for the * * self-report items as well as one dataset * * with all of the data for public use. * * * INPUT: CxE, s=site, y=year, c=cohort * * * * OUTPUT: SCM3SC1 * ************************************************************; ** Fill out information below for data processed in this run **; ** Name library holding SAS input data files **; LIBNAME SASIN "l:/datasets/child/sociometrics/u" ; ** Specify cohort number **; %let coh = 1 ; ** Enter year of data collection **; %let yr = 3 ; /* Grade 2 */ *************** DO NOT MODIFY BELOW THIS LINE ******************************; ** Specify library for output datasets **; LIBNAME SASOUT "d:\work\sociometrics\year 3" ; ** 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 SCM1 ; SET SASIN.C&yr.E ; **Need to convert the responses for SR1-8 from yes/no to numbers (1,0)**; if C&yr.ESR1 in ('Y', 'N') then C&yr.ESR1x = (C&yr.ESR1 = 'Y'); if C&yr.ESR2 in ('Y', 'N') then C&yr.ESR2x = (C&yr.ESR2 = 'Y'); if C&yr.ESR3 in ('Y', 'N') then C&yr.ESR3x = (C&yr.ESR3 = 'Y'); if C&yr.ESR4 in ('Y', 'N') then C&yr.ESR4x = (C&yr.ESR4 = 'Y'); if C&yr.ESR5 in ('Y', 'N') then C&yr.ESR5x = (C&yr.ESR5 = 'Y'); if C&yr.ESR6 in ('Y', 'N') then C&yr.ESR6x = (C&yr.ESR6 = 'Y'); if C&yr.ESR7 in ('Y', 'N') then C&yr.ESR7x = (C&yr.ESR7 = 'Y'); if C&yr.ESR8 in ('Y', 'N') then C&yr.ESR8x = (C&yr.ESR8 = 'Y'); drop C&yr.ESR1-C&yr.ESR8; RUN; DATA NEW; SET SCM1; RENAME C&yr.ESR1x = C&yr.ESR1 C&yr.ESR2x = C&yr.ESR2 C&yr.ESR3x = C&yr.ESR3 C&yr.ESR4x = C&yr.ESR4 C&yr.ESR5x = C&yr.ESR5 C&yr.ESR6x = C&yr.ESR6 C&yr.ESR7x = C&yr.ESR7 C&yr.ESR8x = C&yr.ESR8; PROC SORT ; BY SITE TCID ; **Reverse Score items before creating subscale**; DATA NEW2; SET NEW; C&yr.ESR3r=1-C&yr.ESR3; C&yr.ESR6r=1-C&yr.ESR6; C&yr.ESR7r=1-C&yr.ESR7; PROC SORT; BY SITE TCID; **Merge with allkey file**; DATA SCM2 ; MERGE NEW2 (IN=SCM) ALL.ALLKEY&coh. (IN=ALL) ; BY SITE TCID ; IF SCM AND ALL ; /* Specify definitions for SCALE VARIABLES below: ** */ %let INDATA = SCM2 ; ************************************************************; %let var_name = SCM&yr.SCS ; %let var_labl = %str(School Satisfaction - Sociometrics ) ; %let var_list = %str(C&yr.ESR1 C&yr.ESR2 C&yr.ESR3 C&yr.ESR4 C&yr.ESR5 C&yr.ESR6 C&yr.ESR7 C&yr.ESR8) ; %linsum ; ************************************************************; DATA SASOUT.SCM&yr.SC&coh. (label="Scored Sociometrics Y&yr. C&coh.") ; SET SCM2; **This keeps all of the data from the original dataset, CxE, and creates a scored dataset which includes the one subscale**; Keep site tcid cohort sitecode year C&yr.ESCHID C&yr.ETCHID C&yr.EROSTR SCM&yr.SCS C&yr.ESR1-C&yr.ESR2 C&yr.ESR3r C&yr.ESR4 C&yr.ESR5 C&yr.ESR6r C&yr.ESR7r C&yr.ESR8 C&yr.EZLMS3 C&yr.EZLMSu C&yr.EZLLS3 C&yr.EZLLSU C&yr.EZAGGS C&yr.EZWDRS C&yr.EZPROS C&yr.EZHYPS C&yr.EZVICS C&yr.EZPRF3 C&yr.EZSIM3 C&yr.EZPRFU C&yr.EZSIMU C&yr.EGLLSU C&yr.EGLLS3 C&yr.EGLMSU C&yr.EGLMS3 C&yr.EGAGGS C&yr.EGHYPS C&yr.EGPROS C&yr.EGVICS C&yr.EGWDRS C&yr.EGPRFU C&yr.EGSIMU C&yr.EGPRF3 C&yr.EGSIM3 C&yr.ESTAT3 C&yr.ESTATU C&yr.EGSTA3 C&yr.EGSTAT C&yr.ECLASS C&yr.EVOTEE C&yr.ELMS3 C&yr.ELMSU C&yr.ELLS3 C&yr.ELLSU C&yr.EAGGS C&yr.EWDRS C&yr.EWDRS C&yr.EPROS C&yr.EHYPS C&yr.EVICS C&yr.ERR1-C&yr.ERR32 C&yr.EDK1-C&yr.EDK32 C&yr.ESEX C&yr.EPERM C&yr.ERMAX C&yr.EPRATE C&yr.ERRGIV C&yr.ERRREC C&yr.ERRSTD C&yr.EG TREATMNT NORM SEX RACE C&yr.EG C&yr.ESR9-C&yr.ESR21 TCID5; LABEL C&yr.ESR1="Self-Report 1: School fun?" C&yr.ESR2="Self-Report 2: Nice things happen?" C&yr.ESR3r="Self-Report 3: Feel unhappy?" C&yr.ESR4="Self-Report 4: Like your school?" C&yr.ESR5="Self-Report 5: Kids to play with?" C&yr.ESR6r="Self-Report 6: Lonely at school?" C&yr.ESR7r="Self-Report 7: Hard to make friends?" C&yr.ESR8="Self-Report 8: Kids like you?"; run; proc contents; run ; proc freq; table SCM&yr.SCS C&yr.ESR1-C&yr.ESR2 C&yr.ESR3r C&yr.ESR4 C&yr.ESR5 C&yr.ESR6r C&yr.ESR7r C&yr.ESR8; run;