## SAS Textbook Examples

An Introduction to Categorical Analysis by Alan
Agresti

Chapter 9 – Models for Matched Pairs

**9****.1
Comparing Dependent Proportions**

**9****.1.1
McNemar Test**

In SAS proc freq we can request McNemar test by using
option **agree** after the **tables** statement. Notice that in the book
the McNemar test is done in terms of z-statistic, while in SAS it is done as a
chi-square statistic.

data rating; input rating1 rating2 count; cards; 1 1 794 1 0 150 0 1 86 0 0 570 ; run; proc freq data = rating; weight count; tables rating1*rating2 /agree; run;

The FREQ Procedure Table of rating1 by rating2 rating1 rating2 Frequency| Percent | Row Pct | Col Pct | 0| 1| Total ---------+--------+--------+ 0 | 570 | 86 | 656 | 35.63 | 5.38 | 41.00 | 86.89 | 13.11 | | 79.17 | 9.77 | ---------+--------+--------+ 1 | 150 | 794 | 944 | 9.38 | 49.63 | 59.00 | 15.89 | 84.11 | | 20.83 | 90.23 | ---------+--------+--------+ Total 720 880 1600 45.00 55.00 100.00 Statistics for Table of rating1 by rating2 McNemar's Test ------------------------ Statistic (S) 17.3559 DF 1 Pr > S <.0001 Simple Kappa Coefficient -------------------------------- Kappa 0.6996 ASE 0.0180 95% Lower Conf Limit 0.6644 95% Upper Conf Limit 0.7348 Sample Size = 1600

**9****.1.2
Estimating Differences of Proportions**

**9****.2
Logistic Regression for Matched Pairs**

**9****.2.1
Connection between McNemar and Cochran-Mantel-Haenszel Tests**