Categorical Data Analysis: Chapter 3
data respire;
input center treatment $ response $ count @@;
n_response=(response='y');
datalines;
1 test y 29 1 test n 16
1 placebo y 14 1 placebo n 31
2 test y 37 2 test n 8
2 placebo y 24 2 placebo n 21
;
proc freq order=data;
weight count;
tables center*treatment*response /
nocol nopct chisq cmh(mf);
run;
proc glm;
class center treatment;
freq count;
model n_response=center treatment;
estimate 'direction' treatment -1 1;
run;
data stress;
input region $ stress $ outcome $ count @@;
n_outcome=(outcome='f');
datalines;
urban low f 48 urban low u 12
urban high f 96 urban high u 94
rural low f 55 rural low u 135
rural high f 7 rural high u 53
;
proc freq order=data;
weight count;
tables region*stress*outcome / chisq cmh nocol nopct;
run;
data soft;
input gender $ country $ question $ count @@;
datalines;
male American y 29 male American n 6
male British y 19 male British n 15
female American y 7 female American n 23
female British y 24 female British n 29
;
proc freq order=data;
weight count;
tables gender*country*question /
chisq cmh nocol nopct;
run;
ods graphics on;
proc freq order=data;
weight count;
tables gender*country*question / riskdiff(cl=(wald) correct) measures
plots=(riskdiffplot oddsratioplot(logbase=2));
run;
ods graphics off;
data ca;
input gender $ ECG $ disease $ count;
datalines;
female <0.1 yes 4
female <0.1 no 11
female >=0.1 yes 8
female >=0.1 no 10
male <0.1 yes 9
male <0.1 no 9
male >=0.1 yes 21
male >=0.1 no 6
;
proc freq;
weight count;
tables gender*disease / nocol nopct chisq;
tables gender*ECG*disease / nocol nopct cmh chisq measures;
run;
data exercise;
input location $ program $ outcome $ count @@;
datalines;
downtown office good 12 downtown office not 5
downtown home good 3 downtown home not 5
satellite office good 6 satellite office not 1
satellite home good 1 satellite home not 3
;
proc freq order=data;
weight count;
tables location*program*outcome /cmh(mf);
exact comor eqor;
run;