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
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
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
Thanks Steve!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: