BookmarkSubscribeRSS Feed
birpech0
Calcite | Level 5

Hello there,

 

I would like to ask if there is a way to specify not only the initial seed number, but a seed for each replication when using replicate in PROC surveyselect?

The background of my question is, I want to compare two ways to do 2-stage-sampling in PROC survey select, one using replicate and one using loops. The latter results should be correct, so I have a benchmark. But as both procedures (hopefully) do the same things in different order, I cannot compare them properly with only the initial seed number. Without controlling for subsequent draws, I cannot decide if different results stem from random influences or if there is some systematic difference (i.e. some mistake).

 

PS. I had problems in sending this message, so I hope there was not double posting.

 

Thanks for your help

Birgit

2 REPLIES 2
PGStats
Opal | Level 21

You can get initial seeds for each stratum in stratified sampling but not for each replicate in replicated sampling. So, simulate the later with the former.

 

data c;
set sashelp.class;
do rep = 1 to 10;
    output;
    end;
run;

proc sort data=c; by rep; run;

proc surveyselect data=c out=samples seed=12345 outseed sampsize=12; 
strata rep;
run;
;

data _null_;
do until(last.rep);
    set samples; by rep;
    end;
call execute(catt(
    "proc surveyselect data=sashelp.class out=s sampsize=12 seed=",
    initialSeed,
    "; run; proc append base=sample2 data=s; run;"));
run;

Samples (pseudo replicated samples) and Sample2 (samples from a loop) are the same.

PG
birpech0
Calcite | Level 5
Thanks so much for your help! This is very useful and time-saving.

##- Please type your reply above this line. Simple formatting, no
attachments. -##

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 891 views
  • 2 likes
  • 2 in conversation