turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Trying to perform a chi squared test using Surveyf...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-31-2018 02:10 PM

Hello,

I am using Surveyfreq to calculate Chi-square results (among other things) for a complex survey data set. Some of the table cells in a two-way table have zero values, which results in the following warning message:

**"Note: Chi-square tests cannot be computed for table XX by YY because at least one table cell has 0 frequency."**

I have tried to suppress the cells with 0 frequency using the NOSPARSE option in the table statement, which does suppress the values for the table, but does not have an effect on the Chi-square tests. I've tried to find it in the SAS literature, but have not been able to find it so far.

Though I don't think it is necessary to address my question, here is the key section of code:

Proc surveyfreq data=SCM_SORT;

by _state;

weight _LLCPWT;

Tables scntmel1*GHSTATUS/row cl nosparse chisq(secondorder);

ODS Output CrossTabs=Freqout1;

Format GHSTATUS status. scntmel1 Always.;

run;

This must be an easy and fairly common question. My search of the community identifies one thread from last October, but I was unable to see a solution in that thread.

Thanks in advance for your guidance.

Accepted Solutions

Solution

02-06-2018
03:31 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ddormer

02-01-2018 10:06 AM

http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_surveyfreq_d...

For the time being, if you want SurveyFreq to do the computations and you want to use zero as the standard error/design effect/covariance for the missing cells, you can do the following:

Construct a dataset that has one observation for each missing table cell, and assign a small weight (relative to the real survey weights) to each of these observations. Merge that dataset with the analysis dataset. Due to the small weights, these additional observations should not affect the estimates of proportions and totals -- but will give the formerly missing cells one observation each, and standard errors of zero, and SurveyFreq will compute the chi-squares.

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ddormer

01-31-2018 03:49 PM

See if there’s an EXACT statement/option. That’s what I use in PROC FREQ.

Note that I’ve moved this to the Stats forum.

Note that I’ve moved this to the Stats forum.

Solution

02-06-2018
03:31 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ddormer

02-01-2018 10:06 AM

http://support.sas.com/documentation/cdl/en/statug/65328/HTML/default/viewer.htm#statug_surveyfreq_d...

For the time being, if you want SurveyFreq to do the computations and you want to use zero as the standard error/design effect/covariance for the missing cells, you can do the following:

Construct a dataset that has one observation for each missing table cell, and assign a small weight (relative to the real survey weights) to each of these observations. Merge that dataset with the analysis dataset. Due to the small weights, these additional observations should not affect the estimates of proportions and totals -- but will give the formerly missing cells one observation each, and standard errors of zero, and SurveyFreq will compute the chi-squares.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to SAS_Rob

02-06-2018 03:32 PM

Thank you. I was working my way towards that conclusion, but your solution is perfect.