/* SAS analysis of 2 by 2 tables */ /* Inference for the difference of two proportions (independent samples) */ /* We use the Christmas tree data given in class */ DATA xmastree; INPUT sample $ treetype $ number; cards; rural natural 64 urban natural 89 rural artific 96 urban artific 172 ; run; /* In the TABLES statement below, the first variable listed is the row variable */ /* and the second variable listed is the column variable. */ PROC FREQ DATA = xmastree ORDER=DATA; TABLES sample*treetype / chisq; WEIGHT number; run; /* SAS does not print the CI for pi_1 - pi_2, but the two-sided P-value for testing */ /* H0: pi_1 = pi_2 is given (0.2218) in the "Chi-square" row of the output. */ /* ****************************************************************************** */ /* Small-sample inference for the difference of two proportions (independent samples) */ /* Can use Fisher's exact test with the FISHER option: */ DATA flatrees; INPUT county forest $ number; cards; 1 pine 1 2 pine 4 1 nonpine 5 2 nonpine 2 ; run; /* In the TABLES statement below, the first variable listed is the row variable */ /* and the second variable listed is the column variable. */ PROC FREQ DATA = flatrees ORDER=DATA; TABLES county*forest / FISHER; WEIGHT number; run; /* P-value given as 0.1212. */