SAS Examples: Survey Select

Last updated:
Table of Contents

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

Sample fixed number of rows

Sample N (N=100) rows from <library>.<input_table>, save result into <library>.<output_table>.

proc surveyselect data=<library>.<input_table>
    n=100 seed=42 out=<library>.<output_table>;
run;

Sample a given fraction of the rows

Sample N% of the rows from <library>.<input_table>, save result into <library>.<output_table>.

rate ranges from 0 (sample no rows) to 1 (sample all rows)

proc surveyselect data=<library>.<input_table>
    rate=0.2 seed=42 out=<library>.<output_table>;
run;

Stratified sampling

Sample (N * the amount of strata) rows from <library>.<input_table>, save result into <library>.<output_table>.

It will throw an error if the rarest class for <stratum_column> has less than N rows.

proc surveyselect data=<library>.<input_table>
    n=100 seed=42 out=<library>.<output_table>;
    strata <stratum_column>;
run;

References

Dialogue & Discussion