Documentation Example 1 for PROC SURVEYMEANS
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: SVMEX1 */
/* TITLE: Documentation Example 1 for PROC SURVEYMEANS */
/* PRODUCT: STAT */
/* SYSTEM: ALL */
/* KEYS: survey sampling, categorical data analysis */
/* KEYS: stratification, clustering */
/* KEYS: unequal weighting, descriptive statistics */
/* PROCS: SURVEYMEANS */
/* DATA: */
/* */
/* SUPPORT: sasaba */
/* REF: PROC SURVEYMEANS, Example 1 */
/* */
/* MISC: Stratified Cluster Sample Design */
/* */
/****************************************************************/
data IceCreamStudy;
input Grade StudyGroup Spending @@;
if (Spending < 10) then Group='less';
else Group='more';
datalines;
7 34 7 7 34 7 7 412 4 9 27 14
7 34 2 9 230 15 9 27 15 7 501 2
9 230 8 9 230 7 7 501 3 8 59 20
7 403 4 7 403 11 8 59 13 8 59 17
8 143 12 8 143 16 8 59 18 9 235 9
8 143 10 9 312 8 9 235 6 9 235 11
9 312 10 7 321 6 8 156 19 8 156 14
7 321 3 7 321 12 7 489 2 7 489 9
7 78 1 7 78 10 7 489 2 7 156 1
7 78 6 7 412 6 7 156 2 9 301 8
;
data StudyGroups;
input Grade _total_;
datalines;
7 608
8 252
9 403
;
data IceCreamStudy;
set IceCreamStudy;
if Grade=7 then Prob=8/608;
if Grade=8 then Prob=3/252;
if Grade=9 then Prob=5/403;
Weight=1/Prob;
run;
title1 'Analysis of Ice Cream Spending';
proc surveymeans data=IceCreamStudy total=StudyGroups;
strata Grade / list;
cluster StudyGroup;
var Spending Group;
weight Weight;
run;