SAS
data xxx;
input int $ trt $ no;
datalines;
mild R 13
mode R 0
sev R 2
mild T 13
mode T 3
sev T 0
;
run;
proc freq data = xxx ;
weight no ;
tables trt *int /chisq ;
run ;
data respire;
input treat $ outcome $ count ;
cards;
test f 40
test u 20
placebo f 16
placebo u 48;
proc freq;
weight count;
tables treat*outcome/measures chisq;
run;

참고파일
Sas_web.pdf
#SAS Code for Confidence Intervals for a Proportion
data veg;
input response $ count;
datalines;
no 25
yes 0
;
run ;
proc freq data=veg;
weight count;
tables response / binomial(ac wilson exact jeffreys) alpha=.05;
run;
#SAS Code for Chi-Squared, Measures of Association, and
Residuals for Data on Education
data table;
input degree belief $ count @@;
datalines;
1 1 9 1 2 8 1 3 27 1 4 8 1 5 47 1 6 236
2 1 23 2 2 39 2 3 88 2 4 49 2 5 179 2 6 706
3 1 28 3 2 48 3 3 89 3 4 19 3 5 104 3 6 293
;
run ;
proc freq order=data;
weight count;
tables degree*belief / chisq expected measures cmh1;
run ;
proc genmod order=data; class degree belief;
model count = degree belief / dist=poi link=log residuals;
run;
#: SAS Code for Confidence Intervals for 2×2 Table
data example;
input group $ outcome $ count @@;
datalines;
placebo yes 2 placebo no 18 active yes 7 active no 13
;
proc freq order=data; weight count;
tables group*outcome / riskdiff(CL=(WALD MN)) measures;
* MN = Miettinen and Nurminen inverted score test;
run;
#SAS Code for Fisher’s Exact Test and Confidence Intervals
for Odds Ratio
data fisher;
input poured guess count @@;
datalines;
1 1 3 1 2 1 2 1 1 2 2 3
;
proc freq; weight count;
tables poured*guess / measures riskdiff;
exact fisher or / alpha=.05;
proc logistic descending;
freq count;
model guess = poured / clodds=pl;
run;
# SAS Code for “Exact” Confidence Intervals for 2×2 Table
data example;
input group $ outcome $ count @@;
datalines;
placebo yes 2 placebo no 18 active yes 7 active no 13
;
proc freq order=data; weight count;
tables group*outcome ;
exact or riskdiff(CL=(MN)) ;
run;
proc freq order=data; weight count;
tables group*outcome ;
exact riskdiff(method=score);
* exact unconditional inverting two one-sided score tests;
run;
#SAS Code for Binary GLMs for Snoring Data
data glm;
input snoring disease total @@;
datalines;
0 24 1379 2 35 638 4 21 213 5 30 254
;
proc genmod; model disease/total = snoring / dist=bin link=identity;
proc genmod; model disease/total = snoring / dist=bin link=logit LRCI;
proc genmod; model disease/total = snoring / dist=bin link=probit;
run;