BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

I have data formatted as follows:

 

data have;
 input ID DOSENUM TRTN RESULT $ @@;
 cards;
 1	1	1	Y
 1	2	1	N
 1	3	1	N
 2	1	1	N
 2	2	1	N
 2	3	1	Y
 3	1	1	N
 3	2	1	Y
 4	1	2	N
 4	2	2	N
 4	3	2	N
 5	1	2	N
 5	2	2	Y
 6	1	2	N
 6	2	2	Y
 6	3	2	Y
 ;
run;

I want to find the p-value of Fisher's exact test comparing TRTN=1 to TRTN=2 for each dose. I am having a bit difficulty conceptualizing what needs to be tabled in PROC FREQ... I was thinking of doing the following, but am unsure if it gives me the p-value I want.

proc freq data= have; by DOSENUM; tables TRTN*RESULT/ fisher; run;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Alternatively, add DOSENUM as a stratification variable to the TABLES statement:

tables DOSENUM*TRTN*RESULT/ fisher;

With that you can use the existing (unsorted) HAVE dataset, omit the BY statement and still obtain the same result: Fisher's exact test applied separately to the three dose groups.

 

However, from your description ("the p-value") I'm not sure if you want three p-values or rather a single p-value, maybe from an exact test for the common odds ratio, adjusting for DOSENUM, if appropriate for your data. This would be a kind of generalization of Fisher's exact test and could be requested by an EXACT statement (exact comor;).

View solution in original post

3 REPLIES 3
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
This gives you p-values, but one assumption of the Fisher's exact test is that the subjects are independent. You appear to have repeated measurements and so a different test is likely necessary.
Rick_SAS
SAS Super FREQ

When you do a BY-group analysis of data, you need to make sure that the data are sorted by the BY-group variable. Before calling PROC FREQ, use the following call to PROC SORT:

proc sort data=have;
   by DOSENUM;
run;
FreelanceReinh
Jade | Level 19

Alternatively, add DOSENUM as a stratification variable to the TABLES statement:

tables DOSENUM*TRTN*RESULT/ fisher;

With that you can use the existing (unsorted) HAVE dataset, omit the BY statement and still obtain the same result: Fisher's exact test applied separately to the three dose groups.

 

However, from your description ("the p-value") I'm not sure if you want three p-values or rather a single p-value, maybe from an exact test for the common odds ratio, adjusting for DOSENUM, if appropriate for your data. This would be a kind of generalization of Fisher's exact test and could be requested by an EXACT statement (exact comor;).

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1191 views
  • 6 likes
  • 4 in conversation