Chapter Contents |
Previous |
Next |
The SURVEYSELECT Procedure |
PROC SURVEYSELECT requires that the input data set be sorted by the STRATA variables. The following PROC SORT statements sort the Customers data set by the stratification variables State and Type.
proc sort data=Customers; by State Type; run;
The following PROC FREQ statements display the crosstabulation of the Customers data set by State and Type.
proc freq data=Customers; tables State*Type; run;
Figure 63.4 presents the table of State by Type for the 13,471 customers. There are four states and two levels of Type, forming a total of eight strata.
The following PROC SURVEYSELECT statements select a probability sample of customers from the Customers data set according to the stratified sample design.
title1 'Customer Satisfaction Survey'; title2 'Stratified Sampling'; proc surveyselect data=Customers method=srs n=15 seed=1953 out=SampleStrata; strata State Type; run;
The STRATA statement names the stratification variables State and Type. In the PROC SURVEYSELECT statement, the METHOD=SRS option specifies simple random sampling. The N=15 option specifies a sample size of 15 customers for each stratum. If you want to specify different sample sizes for different strata, you can use the N=SAS-data-set option to name a secondary data set that contains the stratum sample sizes. The SEED=1953 option specifies '1953' as the initial seed for random number generation.
Figure 63.5 displays the output from PROC SURVEYSELECT, which summarizes the sample selection. A total of 120 customers are selected.
|
The following PROC PRINT statements display the first 30 observations of the output data set SampleStrata.
title1 'Customer Satisfaction Survey'; title2 'Sample Selected by Stratified Design'; title3 '(First 30 Observations)'; proc print data=SampleStrata(obs=30); run;
Figure 63.6 displays the first 30 observations of the output data set SampleStrata, which contains the sample of 120 customers, 15 customers from each of the 8 strata. The variable SelectionProb contains the selection probability for each customer in the sample. Since customers are selected with equal probability within strata in this design, the selection probability equals the stratum sample size (15) divided by the stratum population size. The selection probabilities differ from stratum to stratum since the population sizes differ. The selection probability for each customer in the first stratum (State=`AL' and Type=`New') is 0.012116, and the selection probability is 0.021246 for customers in the second stratum. The variable SamplingWeight contains the sampling weights, which are computed as inverse selection probabilities.
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.