Lapis Lazuli | Level 10

## How do I get the Odds ratio in Fisher Exact Test

Dear Experts,

I used the Fisher Exact test to estimate the significance of 2 variables. It returns exact pValue but I failed to get the Odds ratio for the method.

``````proc freq data=Beact.AllinOne;
tables var1*var2 / fisher norow nocol;
run;``````

Kindly suggest the key code to get the Odds ratio for Fisher Exact Test.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

## Re: How do I get the Odds ratio in Fisher Exact Test

Add the EXACT statement and specify the OR option:

EXACT OR;

You can also add OR to the TABLES statement to get the conventional estimates.

4 REPLIES 4
SAS Super FREQ

## Re: How do I get the Odds ratio in Fisher Exact Test

Add the EXACT statement and specify the OR option:

EXACT OR;

You can also add OR to the TABLES statement to get the conventional estimates.

Lapis Lazuli | Level 10

## Re: How do I get the Odds ratio in Fisher Exact Test

Thank you for your response @Rick_SAS . It works well.

I need one more clarification. Once I get the odds ratio using OR and Exact, I just cross verified with Fisher Exact in R programming.

It returns the same pValue but different Odds ratio. May I know why it differs in the Odds ratio?

SAS Super FREQ

## Re: How do I get the Odds ratio in Fisher Exact Test

I do not know, but here is a link to the PROC FREQ documentation that shows the formulas related to the odds ratio..The OR computation is pretty standard. Did you mean the confidence limits for the OR? SAS supports multiple CIs and sometimes the defaults used by one software differ from the results used by another software package.

All I can suggest is that you find the documentation for whatever R functions you are using and find out how they compute the OR (or CIs for the OR).

Calcite | Level 5

## Re: How do I get the Odds ratio in Fisher Exact Test

It appears SAS FREQ computes the odds ratio solely as the usual OR=(ad)/(bc) method. It does not provide the "exact" OR maximum likelihood estimate which is from Fisher's non-central hypergeometric distribution. These are not the same. It does appear as though SAS will estimate the "exact" confidence limits using Fisher's non-central hypergeometric distribution, but for some reason does not provide the MLE for the OR. The pmf from Fisher's non-central hypergeometric distribution can be considered a likelihood with the OR as the parameter. This is what the fisher.test() function uses in R.

Can SAS add this to SAS/STAT or make it clear how to extract the "exact" OR if this approach already exists?

Discussion stats
• 4 replies
• 3056 views
• 3 likes
• 3 in conversation