简体   繁体   中英

SAS different random number

In SAS you can generate random numbers using a seed at each data step; same seed in 2 diff data steps = same serie of random number in 2 diff data steps.

is there a trick to have 2 different series of random number from the same seed in 2 different data steps? Thanks for the tips.

following India Rocket answers: I should add that i'm meant to use the same distribution across data step.

One way i found way to create a huge dafile of random number and pick in those at each data step. I was wondering if there was something smarter :-)

Check this out:-

/*Using same distribution without changing the seed*/

data A(drop=i);
  call streaminit(123);
  do i = 1 to 5;
    col1 = rand("Normal",0,0.83325) + i; output;
  end;
run;


data E(drop=i);
  call streaminit(123);
  do i = 6 to 10;
    col1 = rand("Normal",0,0.83325) + i; output;
  end;
 run;

Hope this helps :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM