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

Hi,

I am simulating multiple datsets (and concatinating them using the proc append within the macro) using the same seed in the call streaminit but my answers are different. Could anyone suggest a solution

Are they any reasons why my answers my not be reproduced that I am unaware?

Data param;
pr_male=0.7;
pr_all=0.3;
run;

%macro sim (SSB1=, SSB2=, FFV1=, FFV2=,interv=);

Data have&interv ;
set param;
call streaminit(354);
interv=&interv;
do env=1 to 3;
all=rand('bernoulli', pr_all);
do id=1 to 100;
Male = rand('bernoulli', pr_male);
do t=1 to 2;
if t=1 then do;
SSB1 = &SSB1;
FFV1 = &FFV1;
end;
else if t=2 then do;
SSB2 = &SSB2;
FFV2 = &FFV2;
end;
output;
end;
end;
end;
run;

%mend sim;

%sim(SSB1=1, SSB2=0, FFV1=1, FFV2=0,interv=0);
%sim(SSB1=0, SSB2=1, FFV1=0, FFV2=0, interv=1);

 

thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try it again. Make sure there are no errors or warnings in the log. My own test generates two identical streams for pseudo random variables all and Male.

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

Try it again. Make sure there are no errors or warnings in the log. My own test generates two identical streams for pseudo random variables all and Male.

PG
Reeza
Super User

@PGStats would you get the same streams if run on different system? I assume this is true but can't test at the moment. 

PGStats
Opal | Level 21

Using streaminit is supposed to guarantee deterministic sequences, at least on a given system (hardware/version). But I wouldn't assume it does across systems.

PG
SimRock
Obsidian | Level 7
Thank you for your help. I appreciate it

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
  • 4 replies
  • 912 views
  • 2 likes
  • 3 in conversation