DATA Step, Macro, Functions and more

simulating reproducible samples

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

simulating reproducible samples

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

 


Accepted Solutions
Solution
‎11-03-2016 01:51 PM
Respected Advisor
Posts: 4,641

Re: simulating reproducible samples

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


All Replies
Solution
‎11-03-2016 01:51 PM
Respected Advisor
Posts: 4,641

Re: simulating reproducible samples

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
Super User
Posts: 17,783

Re: simulating reproducible samples

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

Respected Advisor
Posts: 4,641

Re: simulating reproducible samples

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
Occasional Contributor
Posts: 14

Re: simulating reproducible samples

Thank you for your help. I appreciate it
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 240 views
  • 2 likes
  • 3 in conversation