Hi I need to create 1000 samples for simulation study. Does any one know how to create a random sample with seeds of time + minute + second ? Thanks
Understand. Thank you!
Can you explain further what you mean by "with seeds of time + minute + second"?
If you want the pseudo random number seed to be based on the computer clock you can 1) omit to set a seed or 2) set the seed to a negative number.
Sure.
I need to run 1000 times, however with the current code, they all have the same seed = 12345. I want to create a macro variable which change every time I pull the sample. One idea is to set the seed macro variable as the time we create the samples.
for example for the first iteration: if time is 10am 1 minute 1 second then %let seed = 100101; second iteration seed become 100111 if each simulation takes 10 seconds. I remember SAS has a function of current time...system....I forget. It create a macro variable of the current time.
Thanks
%macro uniform(datain =, dataout =, size = );
/*pulling a random sample from original data*/
data &dataout. (drop=obsleft sampsize);
sampsize= &size.;
obsleft=totobs;
do while(sampsize>0);
pickit+1;
if ranuni(12345)<sampsize/obsleft then do;
set &datain. point=pickit
nobs=totobs;
output;
sampsize=sampsize-1;
end;
obsleft=obsleft-1;
end;
stop;
run;
%mend uniform;
If datain is always the same, you should use proc surveyselect with option reps=1000.
To get a different seed on every iteration, just omit setting the seed yourself. SAS will use the system clock by default.
I see.. How about "call streaminit(321)"? Does it use seed 321 for 1000 iterations?
That would reset the seed to 321 at every execution of the datastep.
Understand. Thank you!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.