Programming the statistical procedures from SAS

Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 frequency.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 frequency.

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
SAS Employee
Posts: 97

Re: Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 f

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


All Replies
Super User
Posts: 23,771

Re: Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 f

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.
Solution
‎02-06-2018 03:31 PM
SAS Employee
Posts: 97

Re: Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 f

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. 

Occasional Contributor
Posts: 11

Re: Trying to perform a chi squared test using Surveyfreq. "...at least one table cell has 0 f

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

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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