- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.