Example 36.5 Analysis of a 2x2 Contingency Table
This example computes chisquare tests and Fisher’s exact test to compare the probability of coronary heart disease for two types of diet. It also estimates the relative risks and computes exact confidence limits for the odds ratio.
The data set FatComp contains hypothetical data for a casecontrol study of high fat diet and the risk of coronary heart disease. The data are recorded as cell counts, where the variable Count contains the frequencies for each exposure and response combination. The data set is sorted in descending order by the variables Exposure and Response, so that the first cell of the table contains the frequency of positive exposure and positive response. The FORMAT procedure creates formats to identify the type of exposure and response with character values.
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;
In the following PROC FREQ statements, ORDER=DATA option orders the contingency table values by their order in the input data set. The TABLES statement requests a twoway table of Exposure by Response. The CHISQ option produces several chisquare tests, while the RELRISK option produces relative risk measures. The EXACT statement requests the exact Pearson chisquare test and exact confidence limits for the odds ratio.
proc freq data=FatComp order=data;
format Exposure ExpFmt. Response RspFmt.;
tables Exposure*Response / chisq relrisk;
exact pchi or;
weight Count;
title 'CaseControl Study of High Fat/Cholesterol Diet';
run;
The contingency table in Output 36.5.1 displays the variable values so that the first table cell contains the frequency for the first cell in the data set (the frequency of positive exposure and positive response).
Output 36.5.1
Contingency Table
Output 36.5.2 displays the chisquare statistics. Because the expected counts in some of the table cells are small, PROC FREQ gives a warning that the asymptotic chisquare tests might not be appropriate. In this case, the exact tests are appropriate. The alternative hypothesis for this analysis states that coronary heart disease is more likely to be associated with a high fat diet, so a onesided test is desired. Fisher’s exact rightsided test analyzes whether the probability of heart disease in the high fat group exceeds the probability of heart disease in the low fat group; because this value is small, the alternative hypothesis is supported.
The odds ratio, displayed in Output 36.5.3, provides an estimate of the relative risk when an event is rare. This estimate indicates that the odds of heart disease is 8.25 times higher in the high fat diet group; however, the wide confidence limits indicate that this estimate has low precision.
Output 36.5.2
ChiSquare Statistics
1 
4.9597 
0.0259 
1 
5.0975 
0.0240 
1 
3.1879 
0.0742 
1 
4.7441 
0.0294 

0.4644 


0.4212 


0.4644 

11 
0.9967 
0.0367 

0.0334 
0.0393 
Output 36.5.3
Relative Risk
8.2500 
1.1535 
59.0029 
2.9333 
0.8502 
10.1204 
0.3556 
0.1403 
0.9009 
8.2500 


1.1535 
59.0029 


0.8677 
105.5488 