Specifying the proportion, instead of the number, of observations in each stratum of a sample in PROC SURVEYSELECT


Beginning in SAS 9.2 TS2M0 you can use the ALLOC= option in the STRATA statement to specify the sample proportions directly or via a secondary input data set.

For example, suppose you want a sample of 200 to contain equal proportions of males and females with 25% under 21 years old and 75% 21 or older. You'll have four strata with the following sample proportions or rates:

The following DATA step creates a data set for the example containing 5000 observations with a mix of males and females of different ages between 18 and 30.

data frame;
   length Gender $ 1 AgeGroup $ 7;
   do i=1 to 5000;
      if ranuni(34208) le .55 then gender="F";
      else gender="M";
      age=18+int(13*ranuni(4380));
      if age le 21 then AgeGroup='Under21';
      else AgeGroup='Over21';
      output;
   end;
   run; 

These statements create an ALLOC= data set for use in PROC SURVEYSELECT. The ALLOC= data set must contain the variables that define the strata and a variable named _ALLOC_ whose values are the allocation proportions.

data proportions;
   length Gender $ 1 AgeGroup $ 7;
   input Gender $ AgeGroup $ _Alloc_;
   datalines;
M Under21 12.5
M Over21 37.5
F Under21 12.5
F Over21 37.5

These steps sort both input data sets by strata.

proc sort data=frame;
   by Gender AgeGroup;
   run;
proc sort data=proportions;
   by Gender AgeGroup;
   run;

Finally, PROC SURVEYSELECT is used to select a stratified random sample with the desired proportions.

proc surveyselect data=frame method=srs sampsize=200 out=sample noprint;
   strata Gender AgeGroup / alloc=proportions;
   run;

PROC FREQ can be used to verify the sample proportions.

proc freq data=sample;
   tables Gender*AgeGroup;
   run;

In releases prior to SAS 9.2 TS2M0, you first need to convert the desired proportion in each stratum to a number in each stratum and then use PROC SURVEYSELECT.

To convert the stratum rates into stratum numbers, multiply the above rates by the total sample size. For a total sample size of 200, this means you want to select 0.125*200=25 males under the age of 21, 0.375*200=75 males 21 and older, and so on. The following statements perform these computations and display the results.

   data ComputedNs;
      * Desired sample size;
      N=200;         
      * Desired proportions for the final sample;
      M=0.5;         
      F=0.5;
      Under21=0.25;
      Over21=0.75;
      * Compute the sample sizes in each stratum;
      F_Over21  = F * Over21  * N;
      F_Under21 = F * Under21 * N;
      M_Over21  = M * Over21  * N;
      M_Under21 = M * Under21 * N;
      run;
   proc print noobs;
      var F_Over21 F_Under21 M_Over21 M_Under21;
      run;

Here are the resulting stratum sample sizes computed from the desired proportions:

In PROC SURVEYSELECT, specify the stratum sample sizes in the SAMPSIZE= option, making sure they are in the same order as the strata defined by the variables in the STRATA statement.

proc surveyselect data=frame method=srs sampsize=(75 25 75 25) out=sample noprint;
   strata Gender AgeGroup;
   run;

Again, PROC FREQ can be used to verify the proportions.

proc freq data=sample;
   tables Gender*AgeGroup;
   run;