PROC SURVEYMEANS computes incorrect degrees of freedom if the same variable is used on both the STRATA and DOMAIN statements


If the same variable is specified on both the STRATA and DOMAIN statements in PROC SURVEYMEANS, the degrees of freedom and related statistics will be incorrect for any domain analysis involving that variable. The affected statistics are the degrees of freedom, the p-value for the t-test, and all of the confidence limits. The following is a list of the keywords for these statistics:

   CLM
   CLSUM
   DF
   LCLM
   LCLSUM
   T
   UCLM
   UCLSUM 

The degrees of freedom are being computed as the number of PSUs in the current stratum minus the total number of strata. The correct df computation in the domain analysis is the total number of PSUs minus the total number of strata.

To circumvent this problem, create a new domain variable that is equal to the stratum variable and use the new variable in the DOMAIN statement. For example:

data a;
   input s y; 
   datalines;
 1  1
 1  2
 1  4
 2  3
 2  5
 2  8
 ;
run;
title 'Incorrect df and related stats in domain analysis';
proc surveymeans all;
   strata s;
   var y;
   domain s;
   run;
title 'Circumvention and Correct domain analysis';
data a;
   set a;
   d=s;
   run;
proc surveymeans all;
   strata s;
   var y;
   domain d;
   run;