Professional Documents
Culture Documents
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=
OUT=
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.
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;
/*
/*
/*
/*
/*
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;
/*
/*
/*
/*
/*
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