Programming the statistical procedures from SAS

PROC SURVEYSELECT Replicates

Reply
Frequent Contributor
Posts: 139

PROC SURVEYSELECT Replicates

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
Respected Advisor
Posts: 3,780

Re: PROC SURVEYSELECT Replicates

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]
Ask a Question
Discussion stats
  • 1 reply
  • 210 views
  • 0 likes
  • 2 in conversation