The FREQ Procedure

Example 4: Analyzing a 2×2 Contingency Table

Procedure features:
PROC FREQ statement option:
 ORDER=
EXACT statement
TABLES statement options:
 CHISQ RELRISK
WEIGHT statement
Other features:
 FORMAT procedure SORT procedure

This example

• creates a two-way contingency table using existing cell counts

• sorts the data in descending order so that the first table cell contains the frequency of positive exposure and positive response

• computes chi-square tests, exact Pearson chi-square test, and Fisher's exact test to compare the probability of coronary heart disease for two types of diet

• computes estimates of the relative risk and 95 percent exact confidence limits for the odds ratio.

`options nodate pageno=1 linesize=84 pagesize=64;`
 ```proc format; value expfmt 1='High Cholesterol Diet' 0='Low Cholesterol Diet'; value rspfmt 1='Yes' 0='No'; run;```
 ```data fatcomp; input Exposure Response Count; label response='Heart Disease'; datalines; 0 0 6 0 1 2 1 0 4 1 1 11 ;```
 ```proc sort data=fatcomp; by descending exposure descending response; run;```
 ```proc freq data=fatcomp order=data; weight count;```
 ` tables exposure*response / chisq relrisk;`
 ` exact pchi or;`
 ``` format exposure expfmt. response rspfmt.; title 'Case-Control Study of High Fat/Cholesterol Diet'; run;```

 The contingency table lists the variable values so that the first table cell contains the frequency of positive exposure and response. PROC FREQ does not truncate the formatted variable values that are more than 16 characters but uses multiple lines to show Exposure levels. PROC FREQ displays a warning message that sample size requirements may not be met for the asymptotic chi-square tests. The exact tests are appropriate when sample size is small. Because the alternative hypothesis for this analysis states that coronary heart disease was more likely to be associated with a high-fat diet, a one-sided test is needed. Fisher's exact test (right-sided) tests that the probability of heart disease in the high-fat group exceeds the probability of heart disease in the low-fat group. The odds ratio, which provides an estimate of the relative risk when an event is rare, indicates that the odds of heart disease are 8.25 times higher in the high fat diet group. However, the wide confidence limits indicate that this estimate has low precision.