BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
confused_saser
Obsidian | Level 7

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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:

"Exact test in PROC FREQ"

"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.

View solution in original post

7 REPLIES 7
Reeza
Super User

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!

 

 

DHINESHSHANKAR0
Fluorite | Level 6

can you please try as below

 

tables var1*var2 / chisq exact;

 

or 

 

tables var1*var2 / exact;

ballardw
Super User

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?

PGStats
Opal | Level 21

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;
PG
confused_saser
Obsidian | Level 7

@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

Rick_SAS
SAS Super FREQ

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:

"Exact test in PROC FREQ"

"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.

confused_saser
Obsidian | Level 7

@Rick_SAS thank you for those resources. That is very helpful! 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 7 replies
  • 30367 views
  • 13 likes
  • 6 in conversation