Impact of Order on Proc Surveyselect w/ Seed

Viewed 31

I'm following basic instructions to replicate a Proc Surveyselect step; the instructions include the seed used but it seems depending on the sort order results can still vary (and the instructions don't include anything about sorting). I've been reviewing online documentations and all of the information I'm finding related to sorting and Proc Surveyselect is when a strata is specified. Does sort order impact the results of Proc Surveyselect when a seed is specified (and no strata statements are included)?

proc surveyselect data = dataset groups=10 seed=123456 out=dataset_out; run;

1 Answers

Let's test it out. The answer is yes, but what better way to learn than to test it yourself?

data class;
    set sashelp.class;
run;

/* Create 10 random groups from class */
proc surveyselect 
    data   = class 
    groups = 10 
    seed   = 123456 
    out    = class_sample; 
run;

/* Resort the data */
proc sort data=class;
    by age;
run;

/* Create 10 random groups from the sorted data */
proc surveyselect 
    data   = class 
    groups = 10 
    seed   = 123456 
    out    = class_sample_sorted; 
run;

/* Resort both datasets back by name */
proc sort data=class_sample;
    by name;
run;

proc sort data=class_sample_sorted;
    by name;
run;

/* Compare the difference between assigned groups */
proc compare base    = class_sample 
             compare = class_sample_sorted
             ;
    id name;
    var groupid;
run;

The results from proc compare show that dataset order does indeed matter and will give different sampling results.

enter image description here

Related