OPTIONS LINESIZE=140 PAGESIZE=100 NOCENTER NODATE NONUMBER NOFMTERR; *******************************************************************; * WATCH II Study PROGRAM ; * PROGRAM NAME LOCATION DATE PROGRAMMER ; Title1 "Source:w2ed04p31.SAS WATCH II 5/20/2004 EJS " ; * saved for documentation as w2anal3-prg.txt ; * Description: Mixed Model analysis of Pretest-posttest data ; * with control and intervention group- tables with no effect ; * modifiers ; * Example for Documentation ; * The table title is saved in the following location: ; FILENAME tout "C:\temp\test.txt" ; *******************************************************************; ODS HTML CLOSE; ODS Listing ; DATA d1; INPUT condition $ 14. STATIN $ 9. ID wt interv t int_stat statin_t; LABEL t="Time*Effect*increment:T" wt ="Wt in lbs: WT" interv="Intervention*occurred:INTERV" int_stat="Interv*Increment*of*statin:INT_STAT" statin_t="Time*Increment*of*Statin:STATIN_T"; *condition STATIN ID wt interv t int_stat statin_t; CARDS; 1=Control 0=No 7 156 0 0 0 0 1=Control 0=No 7 192 0 1 0 0 1=Control 0=No 11 193 0 0 0 0 1=Control 0=No 11 214 0 1 0 0 1=Control 0=No 12 189 0 0 0 0 1=Control 1=Yes 17 279 0 0 0 0 1=Control 1=Yes 17 243 0 1 0 1 1=Control 1=Yes 44 179 0 0 0 0 1=Control 1=Yes 44 133 0 1 0 1 1=Control 1=Yes 55 163 0 0 0 0 2=Intervention 0=No 8 185 0 0 0 0 2=Intervention 0=No 8 170 1 1 0 0 2=Intervention 0=No 10 162 0 0 0 0 2=Intervention 0=No 10 173 1 1 0 0 2=Intervention 0=No 14 238 0 0 0 0 2=Intervention 1=Yes 83 199 0 0 0 0 2=Intervention 1=Yes 83 214 1 1 1 1 2=Intervention 1=Yes 89 191 0 0 0 0 2=Intervention 1=Yes 89 300 1 1 1 1 2=Intervention 1=Yes 90 251 0 0 0 0 ; DATA d2; SET d1; IF statin='1=Yes' then delete; PROC PRINT DATA=d2 LABEL; TITLE2 "Test Data"; RUN; *****************************************************************; *** Macro to conduct analyses and produce results-no statins *; *****************************************************************; %MACRO w2anal3 (datain,group,outfile,vname); PROC MIXED DATA=&datain; CLASS id ; MODEL &vname=t interv /solution; RANDOM id; ODS OUTPUT COVPARMS=cp ; ODS OUTPUT SOLUTIONF=est; TITLE2 "Table 1. Overall Mixed model analysis"; RUN; **********************************************; *** Summarize Covariance Estimates *; **********************************************; PROC PRINT DATA=cp; TITLE4 "Covariance Estimates"; RUN; PROC TRANSPOSE DATA=cp OUT=cpt (RENAME=(v1=id_v v2=resid_v) DROP=_NAME_) PREFIX=v; VAR estimate; RUN; PROC PRINT DATA=cpt (OBS=4) NOOBS; RUN; **********************************************; **** Summarize parameter estimates *; **********************************************; PROC PRINT DATA=est; TITLE4 "Estimates of effects"; RUN; PROC TRANSPOSE DATA=est OUT=est1 (RENAME=(v1=b v2=t v3=int ) DROP=_NAME_) PREFIX=v; VAR estimate; RUN; PROC TRANSPOSE DATA=est OUT=est2 (RENAME=(v1=b_se v2=t_se v3=int_se ) DROP=_NAME_) PREFIX=v; VAR stderr; RUN; PROC TRANSPOSE DATA=est OUT=est3 (RENAME=(v1=n) DROP=_NAME_ v2-v3) PREFIX=v; VAR df; RUN; PROC TRANSPOSE DATA=est OUT=est4 (RENAME=(v1=b_p v2=t_p v3=int_p ) DROP=_NAME_) PREFIX=v; VAR probt; RUN; DATA estc (DROP=_LABEL_ n); MERGE est1 est2 est3 est4; nsub=n+1; PROC PRINT DATA=estc; RUN; DATA e2; MERGE cpt estc; RUN; PROC PRINT DATA=e2; RUN; **************************************************; *** Create Output in two rows of a table *; **************************************************; DATA _NULL_; SET e2; FILE &outfile MOD; PUT @1 "&group" @12 nsub 3.0 @16 id_v 5.0 @26 resid_v 5.0 @36 b 5.1 @41 "(" @42 b_se 4.2 ")" @50 t 5.1 @55 "(" @56 t_se 4.2 ")" @62 int 5.1 @67 "(" @68 int_se 4.2 ")"/ @52 "(" @53 t_p 6.4 ")" @64 "(" @65 int_p 6.4 ")" //; RUN; %MEND; RUN; %w2anal3 (datain=d2,group=Test,outfile=tout,vname=wt); RUN;