/*=====================================================================================* Program Name : v_contin.sas Path : c:/sas_macros Program Language : SAS V8.2 Operating System : SunOS 5.8 ________________________________________________________________________________________ Purpose : Validate continuous data analysis such as in demographics summary tables using Proc Report or Proc Tabulate Run Dependencies : None Macro Calls Internal : External : Files Input : Output : one file Program Flow : Macro Assumptions : Macro Parameters : _________________________________________________________________________________________ Version History : Version Date Programmer Description ------- --------- ---------- ----------- 1.0 07NOV2005 sgupta Gupta Programming, www.sassavvy.com, Creation ========================================================================================*/ options nocenter symbolgen mprint mlogic; dm output 'clear'; dm log 'clear'; %*include 'C:\sas_macro\setup.sas'; * Validation macro for continuous variables; * One call for each variable; %macro v_contin(sproc = R /* Proc Report or Proc Tabulate */ ,dsetn = demog /* Data set name */ ,txtvr = drug /* treatment group variable */ ,ctinvr = age /* Continuous variable (numeric variable) */ ,ctinvl = Age /* Continuous variable label */ ,whrcon = %str(*) /* Where expression to subset data set */ ); options formchar = '|_---|+|---+=|-/\<>*' orientation = landscape; title "Validation of &ctinvr in &dsetn data set"; %if &sproc = R %then %do; * PROC REPORT - Continuous Variable; * Temporary statistics variables are created in PROC REPORT; * Statistics will be displayed as columns; * Model Syntax; * proc report data=demog nowindows nocenter missing headline headskip nofs list split='*'; * column ('__' drug, ( ("__ Age __" age= agen age= agemean age= agestd age= agemin age=agemax) )); * define drug /across; * define agen /analysis n format=3. 'N'; * define agemean /analysis mean format=5.3 'Mean'; * define agestd /analysis std format=5.3 'SD'; * define agemin /analysis min format=3. 'Min'; * define agemax /analysis max format=3. 'Max'; * run; * Production code; proc report data=&dsetn nowindows nocenter missing headline headskip nofs list split='*'; * Apply any subset condition; &whrcon; * Add variables to build more columns; column ('__' &txtvr, ( ("__ &ctinvl __" &ctinvr= &ctinvr.n &ctinvr= &ctinvr.mean &ctinvr= &ctinvr.std &ctinvr= &ctinvr.min &ctinvr= &ctinvr.max) )); define &txtvr /across; define &ctinvr.n /analysis n format=3. 'N'; define &ctinvr.mean /analysis mean format=5.3 'Mean'; define &ctinvr.std /analysis std format=5.3 'SD'; define &ctinvr.min /analysis min format=3. 'Min'; define &ctinvr.max /analysis max format=3. 'Max'; run; %end; %else %if &sproc = T %then %do; * PROC TABULATE - Continuous Variable; * Statistics will be displayed as rows; * Easy to get overall total descriptive statistics; * Model syntax; * proc tabulate data=demog missing; * class drug; * var age; * table age = 'Age' * (n='N'*f=8. mean='Mean'*f=5.1 std='Std'*f=5.1 min='Min'*f=3. max='Max'*f=3.) ,(drug=" ")(all = 'Overall'); * run; * Production code; proc tabulate data=&dsetn missing; * Apply any subset condition; &whrcon; class &txtvr; var &ctinvr; * Add variables to build more rows (before comma) and columns (after comma); table &ctinvr = "&ctinvl" * (n='N'*f=8. mean='Mean'*f=5.1 std='Std'*f=5.1 min='Min'*f=3. max='Max'*f=3.) ,(&txtvr=" ")(all = 'Overall'); run; %end; title; %mend v_contin; * Sample calls; * Demog - age variable using proc report; %v_contin(sproc = R /* Proc Report or Proc Tabulate */ ,dsetn = demog /* Data set name */ ,txtvr = drug /* treatment group variable */ ,ctinvr = age /* Continuous variable */ ,ctinvl = Age /* Continuous variable label */ ,whrcon = %str(where seval = 1) /* Where expression to subset data set */ ); * Vitals - tempc variable using proc report; %v_contin(sproc = R /* Proc Report or Proc Tabulate */ ,dsetn = vitals /* Data set name */ ,txtvr = drug /* treatment group variable */ ,ctinvr = tempc /* Continuous variable */ ,ctinvl = Temperature /* Continuous variable label */ ,whrcon = %str(where seval = 1 and visitnm=2) /* Where expression to subset data set */ ); * Demog - age variable using proc tabulate; %v_contin(sproc = T /* Proc Report or Proc Tabulate */ ,dsetn = demog /* Data set name */ ,txtvr = drug /* treatment group variable */ ,ctinvr = age /* Continuous variable */ ,ctinvl = Age /* Continuous variable label */ ,whrcon = %str(where seval = 1) /* Where expression to subset data set */ );