lundi 4 décembre 2017

Reset random number stream

It appears that SAS/IML has the ability to reset it's random number stream (doc link) .

Is there a similar feature for random number routines in the SAS data step?

Based on this post, it seems that subsequent calls to streaminit are ignored within a single datastep.

For example, the below code produces different random numbers for each row:

data want;
  do i = 1 to 2;
    call streaminit(123);  * <-- WANT THIS TO RESET THE STREAM;
    ran1 = rand('uniform');      
    ran2 = rand('uniform');      
    ran3 = rand('uniform');      
    put _all_;
    output;
  end;
run;

Output:

i=1 ran1=0.5817000773 ran2=0.0356216603 ran3=0.0781806207 
i=2 ran1=0.3878454913 ran2=0.3291709244 ran3=0.3615948586 

I would like the output to be:

i=1 ran1=0.5817000773 ran2=0.0356216603 ran3=0.0781806207 
i=2 ran1=0.5817000773 ran2=0.0356216603 ran3=0.0781806207 




Aucun commentaire:

Enregistrer un commentaire