SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eabc0351
Quartz | Level 8

Hello. I would like to run a fisher's exact test. However, my data is weighted so I am using proc surveyfreq to obtain p-values for my contingency tables. The exact option will not work with the proc surveyfreq command. Any suggestions?

 

I should also add that one of my cells is 0. The nosparse option can suppress the cell but I still cannot get a p-value with the chisq option.

 

Thank you.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Watts
SAS Employee

When there's an empty (zero-frequency) table cell, the Rao-Scott chi-square can't be computed because some quantities are undefined/missing. Here's one possible work-around, if you want to use zero as the standard error for the missing cell(s).


1) Construct a data set that contains one observation for each empty table cell, and assign a small weight (relative to the real survey weights) to each of these observations -- e.g., 1e-8.
2) Merge that data set with the analysis dataset. Because of the very small weights, the additional observations should not affect the estimates of proportions and totals. But all table cells will have positive frequency and SURVEYFREQ will compute the Rao-Scott chi-square test.

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

I don't think that there is such a thing as Fisher's Exact test for survey data, as the existence of the survey weights means you aren't dealing with integers in the analysis, which is what Exact tests require (but shhhh don't tell Sir Ronald)

--
Paige Miller
eabc0351
Quartz | Level 8

Yes, that is the error message that I am getting from SAS. @PaigeMiller do you know any solution for getting a p-value with survey data when one of the cells is 0?

Thank you.

PaigeMiller
Diamond | Level 26

PROC SURVEYFREQ has other ways to obtain confidence intervals. There are many choices within the CL option in PROC SURVEYFREQ.

 

https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_surveyfreq_syntax06.htm&docsetVer...

--
Paige Miller
Watts
SAS Employee

When there's an empty (zero-frequency) table cell, the Rao-Scott chi-square can't be computed because some quantities are undefined/missing. Here's one possible work-around, if you want to use zero as the standard error for the missing cell(s).


1) Construct a data set that contains one observation for each empty table cell, and assign a small weight (relative to the real survey weights) to each of these observations -- e.g., 1e-8.
2) Merge that data set with the analysis dataset. Because of the very small weights, the additional observations should not affect the estimates of proportions and totals. But all table cells will have positive frequency and SURVEYFREQ will compute the Rao-Scott chi-square test.

eabc0351
Quartz | Level 8
That worked perfectly without changing the proportions, as you said. Thanks!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4136 views
  • 2 likes
  • 3 in conversation