BookmarkSubscribeRSS Feed
darrylovia
Quartz | Level 8
Hello All

I am trying to run some sampling simulation and found an option in PROC SURVEYSELECT rep=nrep that would let me round repeated samples of a universe.

If my seed is fixed how does PROC SURVEYSELECT get the "seed" for the replicates. My example below compares the REP option vs a MACRO loop. For the proc surveyselect with replicate=1 has the same sample output as the macro loop 1 (just as expected).

I used to have a macro loop through proc surveyselect for repeated samples, but with the REP option PROC SURVEYSELECT is much faster.

Any advice?



proc surveyselect data=sashelp.shoes sampsize=300 method=srs
out=sample_data_rep seed=8 rep=100;
run;

** vs;
%macro loopit;


%do i=1 %to 100;

%let seed=%eval(7+&i);
proc surveyselect data=sashelp.shoes sampsize=300 method=srs
out=sample_data&i seed=&SEED;
run;

proc append base=sample_data_macro data=sample_data&i;
run;

%end;


%mend loopit;
%loopit;

proc compare data=sample_data_rep compare=sample_data_macro;
run;



Darryl
1 REPLY 1
data_null__
Jade | Level 19
These statements should answer your question.

[pre]
proc surveyselect data=sashelp.shoes sampsize=300 method=srs
out=sample_data_rep1 seed=8 rep=1;;
run;
%put _global_;

proc surveyselect data=sashelp.shoes sampsize=300 method=srs
out=sample_data_rep2 seed=&SYSRANEND rep=1;
run;
data sample_data_repA;
set sample_data_rep1 sample_data_rep2(in=in2);
if in2 then replicate=2;
run;
%put _global_;
proc surveyselect data=sashelp.shoes sampsize=300 method=srs
out=sample_data_repB seed=8 rep=2;
run;

proc compare base=sample_data_repA compare=sample_data_repB;
run;
[/pre]

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1701 views
  • 0 likes
  • 2 in conversation