- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For a cell with no observations, the standard error cannot be computed. This is also true for the design effect and the covariances for that cell. So the chi-squares (formulas given in the documentation) are also undefined.
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Note that I’ve moved this to the Stats forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For a cell with no observations, the standard error cannot be computed. This is also true for the design effect and the covariances for that cell. So the chi-squares (formulas given in the documentation) are also undefined.
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
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. I was working my way towards that conclusion, but your solution is perfect.