forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloodpress.sas
163 lines (133 loc) · 4.76 KB
/
bloodpress.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
/* Effect of age, weight, and stress index on blood pressure */
/* Blood pressure tends to increase with age, body mass, and potentially stress.
To investigate the relationship of blood pressure to these variables, a
sample of men in a large corporation was selected. For each subject,
their age (years), body mass (kg), and a stress index (ranges from 0 to 100)
was recorded along with their blood pressure. */
/* 2015-07-20 CJS updated */
dm 'output' clear;
dm 'log' clear;
proc datasets kill; run;
title; footnote; run;
ods graphics on;
ods pdf file='bloodpress-SAS.pdf' style=styles.printer;
TITLE 'Effect of age, weight, and stress on blood pressure';
options nodate nonumber noovp;
*---partdatab;
DATA bloodpress;
infile 'bloodpress.csv' dlm=',' dsd missover firstobs=2;
INPUT Age BloodPressure StressIndex Weight;
run;
*---partdatae;
PROC PRINT DATA=bloodpress;
TITLE2 'raw data';
run;
ods document name=scatter(write);
*---partscatterb;
proc sgscatter data=bloodpress;
title2 'scatter plot matrix';
matrix age stressindex weight bloodpressure;
run;
*---partscattere;
ods document close;
ods document name=reg(write);
*---partlmfitb;
PROC REG DATA=bloodpress plot=all;
TITLE2 'REGRESSION ANALYSIS';
MODEL BloodPressure = age weight StressIndex / clb partial ;
output out=preddata p=predicted r=residual
lclm=lcl_mean uclm=ucl_mean
lcl =lcl_indiv ucl =ucl_indiv;
ods output nobs = lmnobs;
ods output fitstatistics = lmfitstat;
ods output anova = lmanova;
ods output parameterestimates=lmestimates;
run;
*---partlmfite;
ods document close;
ods pdf close;
/********************************************************************/
/* Generate latex code for inclusion into my notes */
title ;
footnote ;
%include '../../MyLaTeXtagset.sas'; run; /* See if my latex tagsets work */
/* the raw data */
ods tagsets.mylatex file="bloodpress-SAS-data.tex" (notop nobot) ;
proc print data=bloodpress noobs label split=' ';
run;
ods tagsets.mylatex close;
proc document name=reg;
list / levels=all;
run;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-scatter' reset=index;
proc document name=scatter;
replay \Sgscatter#1\SGScatter#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;
/* output from reg */
ods tagsets.mylatex file="bloodpress-SAS-lmnobs.tex" (notop nobot) ;
proc print data=lmnobs noobs label split=' ';
var Model Dependent Label N;
run;
ods tagsets.mylatex close;
ods tagsets.mylatex file="bloodpress-SAS-lmanova.tex" (notop nobot) ;
proc print data=lmanova noobs label split=' ';
run;
ods tagsets.mylatex close;
ods tagsets.mylatex file="bloodpress-SAS-lmestimates.tex" (notop nobot) ;
proc print data=lmestimates noobs label split=' ';
run;
ods tagsets.mylatex close;
ods tagsets.mylatex file="bloodpress-SAS-lmpredavg.tex" (notop nobot) ;
proc print data=preddata noobs label split=' ' ;
var age stressindex weight bloodpressure predicted lcl_mean ucl_mean;
run;
ods tagsets.mylatex close;
ods tagsets.mylatex file="bloodpress-SAS-lmpredindiv.tex" (notop nobot) ;
proc print data=preddata noobs label split=' ' ;
var age stressindex weight bloodpressure predicted lcl_indiv ucl_indiv;
run;
ods tagsets.mylatex close;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-obsvspred' reset=index;
proc document name=reg;
replay \Reg#1\MODEL1#1\ObswiseStats#1\BloodPressure#1\DiagnosticPlots#1\ObservedByPredicted#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-residplot' reset=index;
proc document name=reg;
replay \Reg#1\MODEL1#1\ObswiseStats#1\BloodPressure#1\DiagnosticPlots#1\ResidualByPredicted#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-qqplot' reset=index;
proc document name=reg;
replay \Reg#1\MODEL1#1\ObswiseStats#1\BloodPressure#1\DiagnosticPlots#1\QQPlot#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-diagpanel' reset=index;
proc document name=reg;
replay \Reg#1\MODEL1#1\ObswiseStats#1\BloodPressure#1\DiagnosticPlots#1\DiagnosticsPanel#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;
ods listing;
ods graphics on / imagefmt=png imagename='bloodpress-SAS-leverage' reset=index;
proc document name=reg;
replay \Reg#1\MODEL1#1\PartialPlots#1\BloodPressure#1\PartialPlot#1 / dest=listing;
run;
ods graphics off;
ods listing close;
run;