OPTIONS LINESIZE=140 PAGESIZE=100 NOCENTER NODATE NONUMBER NOFMTERR fmtsearch=(current.w2form);; *******************************************************************; * WATCH II Study PROGRAM ; * PROGRAM NAME LOCATION DATE PROGRAMMER ; Title1 "Source:w2py04p72.SAS WATCH II 4/17/2004 EJS,PY" ; * Create Descriptive Table Macro for a dichotomous variable; * with two treatment groups at baseline and follow-up ; * Create Macro: DEMO3 Creates summary Percent and test at ; * two times for two groups ; * Use: w2a04v3.sas7bdat Analysis data set for WATCH II study ; FILENAME tout "J:\Projects\watchII\temp\peikang\output\Table1a.txt" ; *******************************************************************; LIBNAME current v8 "J:\Projects\watchII\data\current"; ODS HTML CLOSE; ODS Listing ; **************************************************************; **************************************************************; *** Read in basic data and limit it to eligible cases ; **************************************************************; **************************************************************; DATA d1; SET current.demv8 (KEEP=id income schoolyr status agev2 condition eligv3 female racethn); IF eligv3=1; *select only eligible subjects; ******************************************; *regroup race into two groups; IF racethn=1 then white=1; ELSE IF racethn in (2,3,4,5,6,7) then white=0; else white=.; *classifu education level based on schoolyr; if schoolyr in (1,2,3) then education = 0; else if schoolyr in (4,5,6,7) then education = 1; else education=.; run; *** Create indicator variable for followup data; *** using cholesterol and follow-up questionnarie; *** First see if cholesterol is not missing ; **************************************************; DATA c1 c2; SET current.w2cholv2 (KEEP=id timeper tc d_lc lc); IF timeper=1 THEN OUTPUT c1; * Subjects with baseline cholesterol; IF timeper=2 THEN OUTPUT c2; * Subjects with follow-up cholesterol; PROC MEANS DATA=c1; TITLE2 "Table 1. Means of baseline Chol Measures"; RUN; PROC MEANS DATA=c2; TITLE2 "Table 1. Means of FU Chol Measures"; RUN; ******************************************; *** Combine with eligibility codes to ; *** create cholesterol follow-up indicator; *******************************************; PROC SORT DATA=c1; BY id; PROC SORT DATA=c2; BY id; PROC SORT DATA=d1; BY id; ********************************************************* *** merge baseline with cholestrol with deogramphic data; ********************************************************; DATA dc1; MERGE c1 (in=a) d1(KEEP=id eligv3); BY id; IF a; * Only keep from Chol data; IF eligv3=1; *select eligible cases; ********************************************************* *** merge follow up with cholestrol with deogramphic data; *********************************************************; DATA dc2 (KEEP=id chol_fu); MERGE c2 (IN=a) d1(KEEP=id eligv3); BY id; IF a; * Only keep from Chol data; IF eligv3=1; *select eligible cases; chol_fu=1; *Indicator for follow-up cholesterol; DATA dc12 (KEEP=id chol_fu); MERGE dc1 dc2; BY id; *****************************************; *** Add indicator of cholesterol follow-up; ******************************************; DATA d2; MERGE d1 dc12; BY id; femalefu=female*chol_fu; *equal to missing if no follow-up chol; whitefu=white*chol_fu; educationfu=education*chol_fu; RUN; PROC MEANS DATA=d2; TITLE2 "Table 2. List of means for demographic data"; RUN; PROC PRINT DATA=D2; RUN; ********************************************************************************; ********************************************************************************; *** End of section to read in basic data and limit it to eligible cases ; ********************************************************************************; ********************************************************************************; ***************************************************************************************; *** Get description at Two Times of a Continuous Variable *; *** Description is Overall and by Treatment Group for baseline and follow-up *; ***************************************************************************************; ***************************************************************************************; *** Get description for v=agev2 *; *** c=condition 1=control *; *** 2=intervention *; *** fu=Chol_fu .=missing follow-up data *; *** 1=Follow-up data present *; ***************************************************************************************; ************************** *** generate table heading; **************************; %MACRO title1 (tableout); DATA _NULL_; FILE &tableout; PUT @1 "Table 1. Simple statistics and Significance test of difference in Demographic variables"/ "between intervention and control at baseline and 1 yr follow up"/ "__________________________________________________________________________________________________"/ "__________________________________________________________________________________________________"/ @1 "Variable Baseline Follow-up"/; PUT @7 " Overall Control Intervention"@52 "p-value" " Control Intervention"@86 "p-value"/ "________________________________________________________________________________________________"/ "________________________________________________________________________________________________"; RUN; %MEND; *********************** *** generate table body **********************; %MACRO table1(dataset=,v=,c=,vfu=,varn=,tableout=); *******************************************************; *** Summarize variable at baseline **; *******************************************************; PROC SUMMARY NOPRINT DATA=&dataset; VAR &v ; CLASS &c; OUTPUT OUT=x2; **************************************; *** Get means for each group *; **************************************; PROC TRANSPOSE DATA=x2 OUT=x3 (RENAME=( col1=v_n col4=v_m col5=v_sd col6=v1_n col9=v1_m col10=v1_sd col11=v2_n col14=v2_m col15=v2_sd ) KEEP= col1 col4 col5 col6 col9 col10 col11 col14 col15); VAR &v ; ********************************************; *** Test equal percent by intervention at baseline; **********************************************; PROC FREQ DATA=&dataset; TABLES &c*&v/chisq; OUTPUT OUT=e1 (RENAME=(p_pchi=v_p) KEEP=p_pchi) CHISQ; RUN; *******************************************************; *** Summarize variable at Follow-up **; *******************************************************; PROC SUMMARY NOPRINT DATA=&dataset; VAR &vfu ; CLASS &c; OUTPUT OUT=f2; **************************************; *** Get means for each group *; **************************************; PROC TRANSPOSE DATA=f2 OUT=f3 (RENAME=( col6=f1_n col9=f1_m col10=f1_sd col11=f2_n col14=f2_m col15=f2_sd) KEEP= col6 col9 col10 col11 col14 col15); VAR &vfu ; ********************************************; *** Test equal percent by intervention at baseline; **********************************************; PROC FREQ DATA=&dataset; TABLES &c*&vfu/chisq; OUTPUT OUT=e2 (RENAME=(p_pchi=f_p) KEEP=p_pchi) CHISQ; RUN; *****************************************; *** Combine data prior to printing table ; *****************************************; DATA x4; MERGE x3 e1 f3 e2; RUN; DATA _NULL_; SET X4; FILE &tableout MOD; PUT @1 "&varn" @9 "Percent" @17 v_m PERCENT6. @28 v1_m PERCENT6. @40 v2_m PERCENT6. @52 v_p 5.4 @63 f1_m PERCENT6. @74 f2_m PERCENT6. @87 f_p 5.4 / @2 @12 "n " @19 v_n 3.0 @30 v1_n 3.0 @42 v2_n 3.0 @65 f1_n 3.0 @76 f2_n 3.0 / "_________________________________________________________________________________________________"; RUN; %MEND; %title1(tout); %table1 (dataset=d2,v=female,c=condition,vfu=femalefu,varn=Female,tableout=tout); %table1 (dataset=d2,v=white,c=condition,vfu=whitefu,varn=White,tableout=tout); %table1 (dataset=d2,v=education,c=condition,vfu=educationfu,varn=College,tableout=tout);