/* SAS code for performing McNemar's test for */ /* analyzing 2 by 2 table: */ /* Comparing two proportions with paired samples.*/ /* We analyze the ice cream data from class: */ DATA icecream; INPUT namebrand $ economy $ number; cards; like like 38 like dislike 92 dislike like 13 dislike dislike 57 ; 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 = icecream ORDER=DATA; TABLES namebrand*economy / agree; 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 (less than .0001) in the "McNemar" section of the output. */ /* ****************************************************************************** */