BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Robin_j
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

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

3 REPLIES 3
SteveDenham
Jade | Level 19

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

Robin_j
Calcite | Level 5

Thanks Steve!

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 8370 views
  • 2 likes
  • 3 in conversation