data prop1;
input a count;
cards;
1 20
2 40
;
proc freq;
tables a /binomial(p=0.5) nopercent nocum;
weight count;
title 'Test of proportion = 0.5';
run;
/* nopercent and nocum suppress additional output that I don't like */
/* p= specifies the Ho proportion, 0.5 is the default, so not */
/* really needed here */
/* by default, SAS will count observations and construct the cont. table */
/* weight names a veriable with the counts */
/* if the contingency table produced by SAS has a=1 and a=2 both with a */
/* count of 1, you forgot the weight statement */
/* In the output, ASE is the asymptotic standard error */
/* the subsequent ci is based on a Z statistic */
/* the exact conf. limits are what are called Clopper-Pearson ci's */
/* this is the most common "exact". You can request others */
/* finally, you get the Z test of p = specified probability */
/* if you add exact binomial; to the code, you get the small sample */
/* exact test (see last proc freq for an example) */
data prop2;
input a b count;
cards;
1 1 20
1 2 40
2 1 50
2 2 50
;
proc freq;
tables a*b /norow nocol nopercent chisq;
weight count;
run;
/* norow nocol and nopercent suppress output I don't like */
/* chisq requests chi-square test and continuity adjusted chi-square */
/* for a 2 x 2 table also gives fisher exact test by default */
/* In the output, Chi-Square is the usual Chi-square statistic */
/* Likelihood Ratio Chi-Square is the drop in Deviance between an */
/* additive model and the model with interaction */
/* Continuity Adf. Chi-Square uses the continuity correction */
/* the other statistics are 557 material (if that) */
/* There are three p-values for Fisher's Exact test */
/* the commonly used one is the two-sided p-value */
data mcnemar;
input a1 a2 count;
cards;
1 1 20
1 2 5
2 1 20
2 2 30
;
proc freq;
table a1*a2 /norow nocol nopercent agree;
weight count;
run;
/* Various measure
proc freq;
table a1*a2 /norow nocol nopercent agree;
weight count;
exact agree;
run;s and tests of agreement, including McNemar's */
/* small sample version of McNemar's */
/* exact statement can be added to any test to use the */
/* small sample randomization distribution instead of an */
/* asymptotic distribution */