Generate random numbers

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.

options pageno=1 nodate ls=80 ps=64;

data u1(keep=x);
&nbsp &nbsp &nbsp seed = 104;
&nbsp &nbsp &nbsp do i = 1 to 5;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp call ranuni(seed, x);
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp output;
&nbsp &nbsp &nbsp end;
&nbsp &nbsp &nbsp call symputx(‘seed’, seed);
run;

data u2(keep=x);
&nbsp &nbsp &nbsp seed = &seed;
&nbsp &nbsp &nbsp do i = 1 to 5;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp call ranuni(seed, x);
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp output;
&nbsp &nbsp &nbsp end;
run;

data all;
&nbsp &nbsp &nbsp set u1 u2;
&nbsp &nbsp &nbsp z = ranuni(104);
run;

proc print label;
&nbsp &nbsp &nbsp label x = ‘Separate Streams’ z = ‘Single Stream’;
run;

Output from the CALL RANUNI Routine
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp Separate&nbsp &nbsp &nbsp Single
Obs&nbsp &nbsp &nbsp Streams&nbsp &nbsp &nbsp Stream

1&nbsp &nbsp &nbsp 0.23611&nbsp &nbsp &nbsp 0.23611
2&nbsp &nbsp &nbsp 0.88923&nbsp &nbsp &nbsp 0.88923
3&nbsp &nbsp &nbsp 0.58173&nbsp &nbsp &nbsp 0.58173
4&nbsp &nbsp &nbsp 0.97746&nbsp &nbsp &nbsp 0.97746
5&nbsp &nbsp &nbsp 0.84667&nbsp &nbsp &nbsp 0.84667
6&nbsp &nbsp &nbsp 0.80484&nbsp &nbsp &nbsp 0.80484
7&nbsp &nbsp &nbsp 0.46983&nbsp &nbsp &nbsp 0.46983
8&nbsp &nbsp &nbsp 0.29594&nbsp &nbsp &nbsp 0.29594
9&nbsp &nbsp &nbsp 0.17858&nbsp &nbsp &nbsp 0.17858
10&nbsp &nbsp &nbsp 0.92292&nbsp &nbsp &nbsp 0.92292

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.