09-05-2016 11:56 AM
You can use some options on the SET statement to achieve this, see example below. Please be aware when using the POINT= option, you also need a STOP statement, as otherwise the DATA Step will loop. Have a look in the doc at the description of the POINT= and NOBS= options. The variable name used in the POINT= option is not written to the output dataset, this is why I use two variables.
data want; getObs = ceil( ranuni(0) * numObs); _getObs = getObs; set sashelp.cars point=_getObs nobs=numObs; output; stop; run;
Also look at Proc SURVEYSELECT for more sophisticated ways to get a random sample from a SAS data set