************************************************************ * PROGRAM: TCL1ST2.SAS Revised Teacher Checklist * * PROGRAMMER: Floyd Hummel * * DATE: 8/25/98 * * REVISION: 01/22/03 by Anne Corrigan for year 2 data * * PURPOSE: Create a SAS dataset containing derived * * variables from the raw data in the sTyBc * * datasets. Program can be modified by * * setting parameters at the beginning of the * * program to specify cohort and time of * * data collection. sTyBc datasets contain * * the six Teacher Checklist variables, as * * well as other data. * * Revised in 1/03 by AMC to use local dataset* * names; input dataset already concatenated * * for sites. * * INPUT: t&yr.b_copy yr=year * * * * OUTPUT: TCL&yr.scores * ************************************************************; OPTIONS PAGESIZE = 71 REPLACE LABEL NUMBER SOURCE; ** Fill out information below for data processed in this run **; ** Enter year of data collection **; %let yr = 2; ** Name library holding SAS input data files **; LIBNAME DATA "D:\sasdata\T&yr.B1TCDataAll" ; ** Specify cohort number **; %let coh = 1 ; DATA TCL1 ; Set data.t&yr.b_copy; /* data for all sites is in t&yr.b_copy */ /* -- below not used -- */ /* some names may not necessarily end in R */ SET SASIN.DT&yr.B&coh.R SASIN.NT&yr.B&coh.R SASIN.PT&yr.B&coh.R SASIN.ST&yr.B&coh.R ; */ PROC SORT ; BY SITE TCID ; *************** DO NOT MODIFY BELOW THIS LINE ******************************; /** Specify library for output datasets **; -- libnames below not used. using same folder libname = data -- LIBNAME SASOUT "c:\fahprg\ckls" ; ** Allkey datasets **; LIBNAME ALL "c:\sasdata" ; */ ** 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)/dim(sumvars) ; else &var_name = . ; end ; keep site tcid &var_name norm treatmnt; proc sort ; by site tcid ; data &INDATA ; merge first &INDATA ; by site tcid ; %mend linsum; *****************************************************************************; /* Data needs to be merged with allkey6 to pick out the target 618 obs. The next three data steps were added by amc. */ /* 1-sort allkey6 */ proc sort data=data.allkey6; by site tcid; run; /* 2-sort raw input dataset */ proc sort data=TCL1; by site tcid; run; /* 3-merge allkey6 and raw dataset. output s/b 618 obs. */ DATA TCL2 ; MERGE TCL1 data.ALLKEY6 (IN=yes) ; BY SITE TCID ; if cohort eq "1"; drop tcid5; if yes then inkey="*"; run; /* Specify definitions for SCALE VARIABLES below: ** */ %let INDATA = TCL2 ; ************************************************************; %let var_name = TCL&yr.RAGG ; %let var_labl = %str(Reactive Aggression - TCL - Year &yr.) ; %let var_list = %str(T&yr.BCL1 T&yr.BCL2 T&yr.BCL3) ; %linsum ; ************************************************************; %let var_name = TCL&yr.PAGG ; %let var_labl = %str(Proactive aggression - TCL - Year &yr.) ; %let var_list = %str(T&yr.BCL4 T&yr.BCL5 T&yr.BCL6) ; %linsum ; ************************************************************; %let var_name = TCL&yr.TOT ; %let var_labl = %str(Total of all - TCL - Year &yr.) ; %let var_list = %str(T&yr.BCL1 T&yr.BCL2 T&yr.BCL3 T&yr.BCL4 T&yr.BCL5 T&yr.BCL6) ; %linsum ; ************************************************************; DATA data.TCL&yr.scores (label="Scored TCL Y&yr. C&coh.") ; SET &INDATA ; KEEP SITE TCID COHORT NORM TREATMNT T&yr.BCL1 T&yr.BCL2 T&yr.BCL3 T&yr.BCL4 T&yr.BCL5 T&yr.BCL6 TCL&yr.RAGG TCL&yr.PAGG TCL&yr.TOT ; PROC FREQ ; TABLES TCL&yr.RAGG TCL&yr.PAGG TCL&yr.TOT ; BY SITE ; RUN ;