-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathBPatPresyncope.sas
215 lines (176 loc) · 5.97 KB
/
BPatPresyncope.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* RCB analysis */
/* Blood Pressure at presyncope under different experimental conditions.
15 subjects were measured while wearing three different stocking to control
presyncope. The order of treatments was randomized within each patient.
Data provided by Clare Protheroe of BPK at SFU in 2011 */
/* ods document statements are used to extract portions for output to LaTeX */
dm 'output' clear;
dm 'log' clear;
proc datasets kill;
run;
options nodate noovp orientation=landscape;;
ods pdf file='BPatPresyncope.pdf';
goptions device=pdf colors=(black) rotate=landscape;
title 'Blood pressure at presyncope';
*---part001b;
proc import file="BPatPresyncope.csv" dbms=csv out=bp replace;
run;
*---part001e;
ods document name=RawData(write);
proc print data=bp(obs=5);
title2 'Part of the raw data';
format bp_at_presyncope 6.1;
run;
ods document close;
proc tabulate data=bp;
title2 'Check that the blocks are complete';
class subject treatment;
var bp_at_presyncope;
table subject, treatment*bp_at_presyncope*sum*f=6.1;
run;
ods document name=Tabulate1(write);
*---part005b;
proc tabulate data=bp;
title2 'A preliminary tabulation';
class treatment;
var bp_at_presyncope;
table treatment, n*f=5.0
bp_at_presyncope*(mean*f=6.2 std*f=6.2);
run;
*---part005e;
ods document close;
proc sort data=bp;
by treatment subject;
run;
ods document name=Profile(write);
*---part010b;
proc sgplot data=bp;
title2 'Profile plot to check for additivity and outliers';
series y=bp_at_presyncope x=subject / group= treatment;;
run;
*---part010e;
ods document close;
*---part015b;
data bp_nooutlier;
set time;
if bp_at_presyncope < 40 then delete;
run;
*---part015e;
ods document name=Tabulate2(write);
proc tabulate data=bp_nooutlier;
title2 'A preliminary tabulation after outliers removed';
class treatment;
var bp_at_presyncope;
table treatment, n*f=5.0
bp_at_presyncope*(mean*f=6.2 std*f=6.2);
run;
ods document close;
/* now for the analysis */
ods graphics on;
ods document name=RCBanal(write);
*---part020b;
proc mixed data=bp_nooutlier plots=all;
title2 'Analysis';
class subject treatment;
model bp_at_presyncope = treatment;
random subject;
lsmeans treatment / diff cl adjust=tukey;
ods output tests3 =tests;
ods output diffs =LSMeansDiffs;
ods output lsmeans=LSmeans;
ods output covparms=Covparms;
run;
*---part020e;
ods document close;
ods graphics off;
/************* Power analysis **************/
ods document name=power(write);
ods graphics on;
*---part050b;
proc power;
title2 'Using a base difference of 5 minutes';
onewayanova
groupmeans = 65 | 65 | 70 /* list the group means */
stddev = 9 /* what is the standard deviation */
alpha = .05 /* what is the alpha level */
power = .80 /* target power */
ntotal = . /* solve for power */
; /* end of the onewayanova statement - don't forget it */
plot x=power min=0.05 max=0.90;
ods output output=poweroutput;
run;
*---part050e;
ods graphics off;
ods document close;
ods pdf close;
/* Now to create files for inclusion in my notes using LaTeX tagsets */
%include "../../MyLaTeXtagset.sas"; run;
title;
footnote;
ods listing;
proc document name=power;
list /levels=all;
run;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-001.tex' (notop nobot);
proc document name=RawData;
obtitle \print#1\Print#1 ;
replay \Print#1\Print#1 / levels=all;;
run;
ods tagsets.mycolorlatex close;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-005.tex' (notop nobot);
proc document name=Tabulate1;
obtitle \Tabulate#1\Report#1\Table#1 ;
replay \Tabulate#1\Report#1\Table#1 / levels=all;;
run;
ods tagsets.mycolorlatex close;
ods graphics on / outputfmt=png imagename="BPatPresyncope-SAS-010" reset=index;
proc document name=profile;
replay \Sgplot#1\SGPlot#1 / levels=all;
run;
ods graphics off;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-015.tex' (notop nobot);
proc document name=Tabulate2;
obtitle \Tabulate#1\Report#1\Table#1 ;
replay \Tabulate#1\Report#1\Table#1 / levels=all;;
run;
ods tagsets.mycolorlatex close;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-020.tex' (notop nobot);
proc print data=tests noobs split=' ' label;
run;
ods tagsets.mycolorlatex close;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-021.tex' (notop nobot);
proc print data=LSmeans noobs split=' ' label;
var treatment estimate stderr;
run;
ods tagsets.mycolorlatex close;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-022.tex' (notop nobot);
proc print data=LSmeansDiffs(drop=effect df tvalue alpha lower upper probt) noobs split=' ' label;
run;
ods tagsets.mycolorlatex close;
ods graphics on / outputfmt=png imagename="BPatPresyncope-SAS-023" reset=index;
proc document name=RCBanal;
obtitle \Mixed#1\ResidualPlots#1\ResidualPanel#1;
replay \Mixed#1\ResidualPlots#1\ResidualPanel#1 / levels=all;
run;
ods graphics off;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-050.tex' (notop nobot);
proc document name=Power;
obtitle \Power#1\OneWayANOVA#1\Output#1 ;
replay \Power#1\OneWayANOVA#1\Output#1 / levels=all;;
run;
ods tagsets.mycolorlatex close;
ods graphics on / outputfmt=png imagename="BPatPresyncope-SAS-051" reset=index;
proc document name=power;
obtitle \Power#1\OneWayANOVA#1\PlotStatement1#1\NTotalPower#1\PowerPlot#1;
replay \Power#1\OneWayANOVA#1\PlotStatement1#1\NTotalPower#1\PowerPlot#1 / levels=all;
run;
ods graphics off;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-052.tex' (notop nobot);
proc print data=covparms noobs split=' ' label;
run;
ods tagsets.mycolorlatex close;
ods tagsets.mycolorlatex file='BPatPresyncope-SAS-053.tex' (notop nobot);
proc print data=poweroutput noobs split=' ' label;
run;
ods tagsets.mycolorlatex close;
ods listing close;