BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ddormer
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS_Rob
SAS Employee

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. 

View solution in original post

3 REPLIES 3
Reeza
Super User
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.
SAS_Rob
SAS Employee

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. 

Ddormer
Obsidian | Level 7

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

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 3198 views
  • 1 like
  • 3 in conversation