Categorical Data Analysis: Chapter 7
data cortisol;
input group $ subject cortisol;
datalines;
I 1 262
I 2 307
I 3 211
I 4 323
I 5 454
I 6 339
I 7 304
I 8 154
I 9 287
I 10 356
II 1 465
II 2 501
II 3 455
II 4 355
II 5 468
II 6 362
III 1 343
III 2 772
III 3 207
III 4 1048
III 5 838
III 6 687
;
proc freq;
tables group*cortisol / noprint cmh2 scores=rank;
run;
proc npar1way wilcoxon;
class group;
var cortisol;
run;
data electrod;
input subject resist1-resist5;
type=1; resist=resist1; output;
type=2; resist=resist2; output;
type=3; resist=resist3; output;
type=4; resist=resist4; output;
type=5; resist=resist5; output;
datalines;
1 500 400 98 200 250
2 660 600 600 75 310
3 250 370 220 250 220
4 72 140 240 33 54
5 135 300 450 430 70
6 27 84 135 190 180
7 100 50 82 73 78
8 105 180 32 58 32
9 90 180 220 34 64
10 200 290 320 280 135
11 15 45 75 88 80
12 160 200 300 300 220
13 250 400 50 50 92
14 170 310 230 20 150
15 66 1000 1050 280 220
16 107 48 26 45 51
;
proc freq;
tables subject*type*resist / noprint cmh2 scores=rank;
run;
proc standard mean=0;
by subject;
var resist;
proc rank;
var resist;
proc freq;
tables subject*type*resist / noprint cmh2;
run;
data ph_vmax;
keep subject ph vmax;
input subject vmax1-vmax4;
ph=6.5; vmax=vmax1; output;
ph=6.9; vmax=vmax2; output;
ph=7.4; vmax=vmax3; output;
ph=7.9; vmax=vmax4; output;
datalines;
1 . 284 310 326
2 . . 261 292
3 . 213 224 240
4 . 222 235 247
5 . . 270 286
6 . . 210 218
7 . 216 234 237
8 . 236 273 283
9 220 249 270 281
10 166 218 244 .
11 227 258 282 286
12 216 . 284 .
13 . . 257 284
14 204 234 268 .
15 . . 258 267
16 . 193 224 235
17 185 222 252 263
18 . 238 301 300
19 . 198 240 .
20 . 235 255 .
21 . 216 238 .
22 . 197 212 219
23 . 234 238 .
24 . . 295 281
25 . . 261 272
;
proc glm;
class ph;
model vmax = subject ph;
lsmeans ph;
estimate 'direction' ph -1 0 0 1 / divisor=3;
run;
proc freq;
tables subject*ph*vmax / noprint cmh2;
tables subject*ph*vmax / noprint cmh2 scores=modridit;
run;
data caries;
input center id group $ before after @@;
datalines;
1 1 W 7 11 1 2 W 20 24 1 3 W 21 25 1 4 W 1 2
1 5 W 3 7 1 6 W 20 23 1 7 W 9 13 1 8 W 2 4
1 9 SF 11 13 1 10 SF 15 18 1 11 APF 7 10 1 12 APF 17 17
1 13 APF 9 11 1 14 APF 1 5 1 15 APF 3 7 2 1 W 10 14
2 2 W 13 17 2 3 W 3 4 2 4 W 4 7 2 5 W 4 9
2 6 SF 15 18 2 7 SF 6 8 2 8 SF 4 6 2 9 SF 18 19
2 10 SF 11 12 2 11 SF 9 9 2 12 SF 4 7 2 13 SF 5 7
2 14 SF 11 14 2 15 SF 4 6 2 16 APF 4 4 2 17 APF 7 7
2 18 APF 0 4 2 19 APF 3 3 2 20 APF 0 1 2 21 APF 8 8
3 1 W 2 4 3 2 W 13 18 3 3 W 9 12 3 4 W 15 18
3 5 W 13 17 3 6 W 2 5 3 7 W 9 12 3 8 SF 4 6
3 9 SF 10 14 3 10 SF 7 11 3 11 SF 14 15 3 12 SF 7 10
3 13 SF 3 6 3 14 SF 9 12 3 15 SF 8 10 3 16 SF 19 19
3 17 SF 10 13 3 18 APF 10 12 3 19 APF 7 11 3 20 APF 13 12
3 21 APF 5 8 3 22 APF 1 3 3 23 APF 8 9 3 24 APF 4 5
3 25 APF 4 7 3 26 APF 14 14 3 27 APF 8 10 3 28 APF 3 5
3 29 APF 11 12 3 30 APF 16 18 3 31 APF 8 8 3 32 APF 0 1
3 33 APF 3 4
;
proc rank nplus1 ties=mean out=ranks;
by center;
var before after;
run;
proc reg noprint;
by center;
model after=before;
output out=residual r=resid;
run;
proc freq;
tables center*group*resid / noprint cmh2;
run;