Solved
New Contributor
Posts: 4

# Proc Survey Select (Iterative Seed)

Hi everyone, I desperately need some assistance, my head is now spinning.  What I am trying to accomplish should not be that difficult.

Here is the code:

data TestB;
set Factor1;
proc surveyselect data=TestB out=subsetB method=srs sampsize=25 seed=123 noprint;
run;

I need to select 200 different samples of 25 in a loop and I want seed to increment by 1....so on the first iteration it will be 123, the next will be 124, etc.....I have tried everything but when I try to set a variable such as

%let SeedA=123  then

SeedA=123+&s ......s is the loop variable and I make ......seed=&SeedA

it does not work.......any suggestions at this point would be greatly appreciated.

Accepted Solutions
Solution
‎03-05-2018 06:00 PM
New Contributor
Posts: 4

## Re: Proc Survey Select (Iterative Seed)

Hi ballardw, thank you!  I was trying to avoid using the replicate options because I would have to change some of my other logic, but this worked out great......I used the reps=200.....and then in a do...loop over 200 replications create the 200 datasets I needed to output.....

data TestA;
set Factor1;
proc surveyselect data=TestA out=subsetA method=srs reps=200 seed=1257 sampsize=25 noprint;
PROC MEANS N MEAN STD SKEWNESS KURTOSIS; VAR T A;/*PROC CORR; VAR T A;*/
run;

%do s=1 %to 200; /*START 200 SIMULATIONS*/

data simA&s;
set subsetA;
where Replicate=&s;
run;

end;

All Replies
PROC Star
Posts: 1,209

## Re: Proc Survey Select (Iterative Seed)

I have to ask why? Why is it important that the procedure uses exactly those seeds?

New Contributor
Posts: 4

## Re: Proc Survey Select (Iterative Seed)

Hi draycut, that was just an example, I just need the seed to change each time for 200 replications that is in a macro  :-)

New Contributor
Posts: 4

## Re: Proc Survey Select (Iterative Seed)

[ Edited ]

I think I need to be more specific, I have both of these in my do loop over 200 replications....I need for the TestA datasets from 1-200 to be different for TestB datasets.....so I cannot use the same do....loop index such as...... seed=&s  .....my code below works great for (1) replication, but I need 200 each with different seed numbers....

data TestA;
set Factor1;
proc surveyselect data=TestA out=subsetA method=srs sampsize=25 seed=123 noprint;
run;

data TestB;
set Factor1;
proc surveyselect data=TestB out=subsetB method=srs sampsize=25 seed=125 noprint;
run;

Super User
Posts: 13,293

## Re: Proc Survey Select (Iterative Seed)

You might want to investigate the REPS = (replicate) which will select n number of samples of your SAMPSIZE and add a variable Replicate to indicate which.

Then either split the set on the replicate variable (not best practice) or do some analysis using BY Replicate to see the behavior of the different samples.

Solution
‎03-05-2018 06:00 PM
New Contributor
Posts: 4

## Re: Proc Survey Select (Iterative Seed)

Hi ballardw, thank you!  I was trying to avoid using the replicate options because I would have to change some of my other logic, but this worked out great......I used the reps=200.....and then in a do...loop over 200 replications create the 200 datasets I needed to output.....

data TestA;
set Factor1;
proc surveyselect data=TestA out=subsetA method=srs reps=200 seed=1257 sampsize=25 noprint;
PROC MEANS N MEAN STD SKEWNESS KURTOSIS; VAR T A;/*PROC CORR; VAR T A;*/
run;

%do s=1 %to 200; /*START 200 SIMULATIONS*/

data simA&s;
set subsetA;
where Replicate=&s;
run;

end;

☑ This topic is solved.