I have a 3 x 2 comparison with expected frequencies low enough to make Fisher's exact preferred over chi-square. I'm trying to figure out how to output the Fisher's exact p-values for the pairwise comparisons to feed into PROC MULTTEST. I found and modified an example from SAS documentation that works for chi-square, but can't figure out how to make it work for Fisher's (see below). I assume I need to replace anything that refers to chi-square in the first line, but can't seem to make it work. The data are structured as one line per subject:
subjectID species examtype
12345 CANINE 1
12346 FELINE 2
12347 EQUINE 1
....
And the output I'm looking for looks like this (copied from running the below using chi-square in SAS 9.4):
ODS OUTPUT chisq(PERSIST)=chisq(WHERE=(statistic="Chi-Square") rename=(Prob=Raw_P));
PROC FREQ DATA= six;
WHERE species in ('CANINE', 'FELINE');
TABLES examtype * species / FISHER;
RUN;
PROC FREQ DATA= six;
WHERE species in ('CANINE', 'EQUINE');
TABLES examtype * species / FISHER;
RUN;
PROC FREQ DATA= six;
WHERE species in ('FELINE', 'EQUINE');
TABLES examtype * species / FISHER;
RUN;
ODS OUTPUT CLEAR;
PROC PRINT NOOBS;
VAR value raw_p;
RUN;
PROC MULTTEST PDATA=chisq BON;
RUN;
Thanks in advance for any help!
Hello @patrick5 and welcome to the SAS Support Communities!
The ODS output datasets for chi-square and Fisher's exact test are structured differently. This should work:
ods output fishersexact(persist)=fisher(where=(name1='XP2_FISH') rename=(nvalue1=raw_p));
Dataset fisher will not contain a variable value, so please delete this from your PROC PRINT step.
Hello @patrick5 and welcome to the SAS Support Communities!
The ODS output datasets for chi-square and Fisher's exact test are structured differently. This should work:
ods output fishersexact(persist)=fisher(where=(name1='XP2_FISH') rename=(nvalue1=raw_p));
Dataset fisher will not contain a variable value, so please delete this from your PROC PRINT step.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.