Setting the seed in Proc Surveyselect

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Setting the seed in Proc Surveyselect

Hello,

I have a question about setting the seed in proc surveyselect.  I have to select a random sample in each of eight regions.  Each region has a separate sampling frame and I plan to create a separate sampling program for each region.  The code I plan to use for each region is

proc surveyselect data=data1 out=data2 method=srs

n=(40 20 40 20 40 20) seed= ;

strata strat1 strat2 ;

run;

I left the seed blank in this code because this is what I am asking about.

How should I choose the seed?  Should I use a program that generates a random number?  Does anyone have an example of such a program?  Is it alright to use the same seed for every region or should I generate a random number for each region's seed?  Another option would be to run the program without a seed, then use the the seed generated by proc surveyselect, which is the time of day from the computer's clock.

Thanks for your help.

Robin


Accepted Solutions
Solution
‎01-31-2014 08:55 AM
Respected Advisor
Posts: 2,655

Re: Setting the seed in Proc Surveyselect

Working backwards--using the clock time will mean that there is a strong possibility that the same individuals will not be selected should you decide to rerun the program.  Thus the use of the seed= option.  You can plug in about anything.  Now comes the tricky part--if you put the selection for regions into a macro loop, the seed will be reset to the value in the seed= option on each step of the loop.  But, if you stack the code and have the same code over and over until you make the 8 datasets (eight consecutive invocations of surveyselect), SAS will only recognize the seed from the first invocation, and continue the random number string from the end of the previous invocation in all subsequent calls.

As far as a particular value, I often use seed=1 or convert the date to a number.  For instance 31Jan2014 means that I would use seed=31012014.

Steve Denham

View solution in original post


All Replies
Solution
‎01-31-2014 08:55 AM
Respected Advisor
Posts: 2,655

Re: Setting the seed in Proc Surveyselect

Working backwards--using the clock time will mean that there is a strong possibility that the same individuals will not be selected should you decide to rerun the program.  Thus the use of the seed= option.  You can plug in about anything.  Now comes the tricky part--if you put the selection for regions into a macro loop, the seed will be reset to the value in the seed= option on each step of the loop.  But, if you stack the code and have the same code over and over until you make the 8 datasets (eight consecutive invocations of surveyselect), SAS will only recognize the seed from the first invocation, and continue the random number string from the end of the previous invocation in all subsequent calls.

As far as a particular value, I often use seed=1 or convert the date to a number.  For instance 31Jan2014 means that I would use seed=31012014.

Steve Denham

New Contributor
Posts: 3

Re: Setting the seed in Proc Surveyselect

Thanks Steve!

SAS Super FREQ
Posts: 3,482

Re: Setting the seed in Proc Surveyselect

If you use SEED=0, then PROC SURVEYSELECT outputs the seed that it used in the ODS "Summary" table. Therefore you can copy/save it and reproduce the computations at a later time.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 662 views
  • 2 likes
  • 3 in conversation