You are on page 1of 3

Details

https://support.sas.com/edu/OLTRN/ECST131/eclibjr/Sampling.htm

Random Samples
Selecting Random Samples
The SURVEYSELECT procedure selects a random sample from a SAS data set.
PROC SURVEYSELECT DATA=name-of-SAS-data-set
OUT=name-of-output-data-set
METHOD=method-of-random-sampling
SEED=seed-value
SAMPSIZE=number of observations desired in sample;
<STRATA stratification-variable(s);>
RUN;
Selected PROC SURVEYSELECT statement options:
DATA=

identifies the data set to be selected from.

OUT=

indicates the name of the output data set.

METHOD=

specifies the random sampling method to be used. For simple random sampling without replacement, use METHOD=SRS. For simple
random sampling with replacement, use METHOD=URS. For other selection methods and details on sampling algorithms, see the SAS
online documentation for PROC SURVEYSELECT.

SEED=

specifies the initial seed for random number generation. If no SEED option is specified, SAS uses the system time as its seed value. This
creates a different random sample every time the procedure is run.

SAMPSIZE=

indicates the number of observations to be included in the sample. To select a certain fraction of the original data set rather than a given
number of observations, use the SAMPRATE= option.

Selected SURVEYSELECT procedure statement:


STRATA

enables the user to specify one or more stratification variables. If no STRATA statement is specified, no stratification takes place.

Other statements and options for the SURVEYSELECT procedure can be found in the SAS online documentation.
Program A shows how to select a certain sample size using the SAMPSIZE= option.
/*Program A*/
proc surveyselect data=Statdata.cars
seed=31475
method=srs
sampsize=12
out=work.CarSample12;
run;

/*
/*
/*
/*
/*

sample from data table */


recommended that you use this option */
simple random sample */
sample size */
sample stored in this data set */

proc print data=work.CarSample12;


run;
NOTE: If you do not provide a seed, you cannot reproduce the sample. It is recommended that you always include a seed when using PROC SURVEYSELECT.

1 of 3

5/25/2016 12:15 PM

Details

https://support.sas.com/edu/OLTRN/ECST131/eclibjr/Sampling.htm

Program B shows how to select a certain percentage of the original sample using the SAMPRATE= option.
/*Program B*/
proc surveyselect data=Statdata.cars
seed=13094425
method=srs
samprate=0.05
out=work.cars12pc;
run;

/*
/*
/*
/*
/*

sample from data table */


recommended that you use this option */
simple random sample */
0 < sampling rate < 1 */
sample stored in this data set */

proc print data=work.cars12pc;


run;

2 of 3

5/25/2016 12:15 PM

Details

https://support.sas.com/edu/OLTRN/ECST131/eclibjr/Sampling.htm

Copyright 2015 SAS Institute Inc., Cary, NC, USA. All rights reserved.

3 of 3

5/25/2016 12:15 PM

You might also like