PROC SURVEYMEANS may report incorrect population totals or rates with BY-processing


When BY processing is used in PROC SURVEYMEANS and the same data set is used for the DATA= and the TOTAL= or RATE= input data sets, then the population totals or the population rates reported by the LIST option on the STRATA statement will be incorrect for all but the first BY group. That is, the incorrect results will occur if you specify

proc surveymeans data=one total=one;
    by byvar;
    strata s / list;
    run;

or

proc surveymeans data=one rate=one;
   by byvar;
   strata s / list;
   run;

Note that BY processing is rarely used in PROC SURVEYMEANS, and the DOMAIN statement should be used to produce the correct domain or subpopulation results.

If BY processing is needed, then this problem can be circumvented by providing the TOTAL= or RATE= data in a different data set than the DATA= data set.