I am trying to run fisher's exact test to see if there are any differences between two categorical variables.
var # 1-->Collection_Center=5 categories
var # 2-->Education= 7 categories
B/c the frequencies in the cross tabs for these 2 variables were < 5, I decided to run a Fisher's exact est instead of a chi-square test for independence.
The following is the code I put into SAS to run fisher's exact test:
proc freq data=baseline_Characteristics; tables collection_center*ca_education/fisher; run;
However, I received this warning from SAS:
WARNING: Computing exact p-values for this problem may require much time and memory. Press the system interrupt key to terminate exact computations.
And sure enough it took so long that I had to stop it.
I have two questions regarding this situation:
1. Can anyone please confirm that I am indeed running the correct statistical test?
2. If I am running the correct test why is it taking so long in SAS and what can I do about it? Am I doing something wrong?
please help!
As PGStats states, use the EXACT / MC statement and specify the number of simulations.
To answer your questions, you might want to read two articles:
"Monte Carlo simulation for contingency tables in SAS"
Briefly, exact tests for your data will try to compute the proportion of 5x7 tables that have the same row and column sums as the observed table and whose chi-square values are more extreme than the observed chi-square statistic. Exact statistics are intended for small tables and for small sample sizes. The long computation time is probably because your sample size is in the hundreds or more, which means that there are zillions of possible tables that fit the marginal sums.
If your sample is too small for the statistical tests you'd like to run, you either:
1. Find a test that accounts for small sample sizes
2. Report descriptive statistics with the caveat that the sample size is too small to determine any significance or generalize.
A Fisher test is the correct test, when Chi-Square is not appropriate, but perhaps there's another option. I'm not seeing anything incorrect with your code.
I'll move this over to the Statistical Procedures forum and others can chime in, who know way more than me on stats topics!
can you please try as below
tables var1*var2 / chisq exact;
or
tables var1*var2 / exact;
I think it would help to provide example data that duplicates the behavior. Only the category variables would be needed. The instructions here will show how to create datastep code from an existing data set that you can paste here in a code box so we can test code or identify problems with the data.
How many records are involved?
You can get a good estimate of Fisher exact test p-value with Monte-Carlo estimation:
proc freq data=baseline_Characteristics;
tables collection_center*ca_education;
exact Fisher / mc n=20000;
run;
@PGStats YES THANKS! I did some googling and decided to use Monte Carlo.
what is the n=2000? I haven't seen that in any online examples so far.
thanks for your help
As PGStats states, use the EXACT / MC statement and specify the number of simulations.
To answer your questions, you might want to read two articles:
"Monte Carlo simulation for contingency tables in SAS"
Briefly, exact tests for your data will try to compute the proportion of 5x7 tables that have the same row and column sums as the observed table and whose chi-square values are more extreme than the observed chi-square statistic. Exact statistics are intended for small tables and for small sample sizes. The long computation time is probably because your sample size is in the hundreds or more, which means that there are zillions of possible tables that fit the marginal sums.
@Rick_SAS thank you for those resources. That is very helpful!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.