This example is taken from Levy and Lemeshow’s Sampling of Populations.
Page 353 cluster sampling with unequal probabilities: probability proportional to size sampling This example uses the hospslct data set. NOTE: The data step creating hspslct2 is necessary to create the weight variable, w2star.
data hspslct2; set hospslct; /*n is 50*/ /*N_i is admiss*/ /* X is 7087, the total number of life-threatening conditions across all the hospitals*/ /*X_i is tl, the total number of life-threatening conditions for each hospital*/ if hospno = 2 then tl = 785; if hospno = 5 then tl = 3404; if hospno = 9 then tl = 778; w2star = (admiss/50)*(7087/tl); run;
proc surveymeans data = hspslct2 n = 4672 mean sum; weight w2star; cluster drawing; var lifethrt dxdead; run;
The SURVEYMEANS Procedure Data Summary Number of Clusters 5 Number of Observations 50 Sum of Weights 51344.9973 Statistics Std Error Variable Mean of Mean Sum Std Dev ------------------------------------------------------------------------ LIFETHRT 0.121904 0.021404 6259.175814 1276.638273 DXDEAD 0.034287 0.022991 1760.471466 1078.465840 ------------------------------------------------------------------------