-
Notifications
You must be signed in to change notification settings - Fork 0
/
Endo_tables.sas
94 lines (80 loc) · 2.74 KB
/
Endo_tables.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
*Center for Innovative Design and Analysis;
*Analyst: Laura Grau, MPH;
*Program: Endo_tables.sas;
*Purpose: Create descriptive table for Pre/Post data for two groups;
*Data format;
*You should have a dataset with one observation per person;
*For each measure, you should have three variables;
*Pre = just the variable name (ie BMI, ALT, AST, etc);
*Post= follow_up_*insert variable name* (ie follow_up_bmi, follow_up_alt, follow_up_ast);
*Change= change_in_*insert variable name* (ie change_in_bmi, change_in_alt, change_in_ast);
%macro univ(data=all, var=, classvar=, ndec=1,stat=mean std, order=);
*check distributions;
proc univariate data=&data;
histogram/normal;
var &var follow_up_&var change_in_&var;
run;
*For Table 1;
ods output table=t1_&var.;
proc tabulate data=&data missing;
var &var ;
table &var , (&stat)/nocellmerge;
run;
*For Table 2;
ods output table=t2_&var.;
proc tabulate data=&data missing;
class &classvar;
var &var follow_up_&var. change_in_&var.;
table &var follow_up_&var. change_in_&var., &classvar.*(&stat)/nocellmerge;
run;
%if &stat=median p25 p75 %then %do;
*Table 1;
data t1_&var.;
length clean $20;
set t1_&var.;
order=ℴ
clean=strip(put(&var._median,8.&ndec))||" ("||strip(put(&var._p25,8.&ndec))||", "||strip(put(&var._p75, 8.&ndec))||")";
variable="&var";
run;
*Table 2;
data t2_&var.;
length clean clean_fu clean_change $20;
set t2_&var.;
order=ℴ
clean=strip(put(&var._median,8.&ndec))||" ("||strip(put(&var._p25,8.&ndec))||", "||strip(put(&var._p75, 8.&ndec))||")";
clean_fu=strip(put(follow_up_&var._median,8.&ndec))||" ("||strip(put(follow_up_&var._p25,8.&ndec))||", "||strip(put(follow_up_&var._p75, 8.&ndec))||")";
clean_change=strip(put(change_in_&var._median,8.&ndec))||" ("||strip(put(change_in_&var._p25,8.&ndec))||", "||strip(put(change_in_&var._p75, 8.&ndec))||")";
variable="&var";
run;
ods output WilcoxonTest=p_&var;
proc npar1way data=&data wilcoxon;
class &classvar;
var change_in_&var.;
run;
%end;
%else %do;
*Table 1;
data t1_&var.;
length clean $20;
set t1_&var.;
order=ℴ
clean=strip(put(&var._mean,8.&ndec))||" ("||strip(put(&var._std, 8.&ndec))||")";
variable="&var";
run;
*Table 2;
data t2_&var.;
length clean clean_fu clean_change $20;
set t2_&var.;
order=ℴ
clean=strip(put(&var._mean,8.&ndec))||" ("||strip(put(&var._std, 8.&ndec))||")";
clean_FU=strip(put(follow_up_&var._mean,8.&ndec))||" ("||strip(put(follow_up_&var._std, 8.&ndec))||")";
clean_change=strip(put(change_in_&var._mean,8.&ndec))||" ("||strip(put(change_in_&var._std, 8.&ndec))||")";
variable="&var";
run;
ods output TTests=p_&var.(where=(variances="Unequal"));
proc ttest data=&data;
class &classvar;
var change_in_&var.;
run;
%end;
%mend;