BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
keithDwright
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
keithDwright
Fluorite | Level 6

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;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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

keithDwright
Fluorite | Level 6

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

 

keithDwright
Fluorite | Level 6

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;

ballardw
Super User

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.

keithDwright
Fluorite | Level 6

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1271 views
  • 1 like
  • 3 in conversation