Functions and CALL Routines |
Returns a random variate from a uniform distribution.
-
seed
-
is the seed value. A new value for seed is returned each time CALL RANUNI is executed.
-
x
-
is a numeric variable. A new value for
the random variate x is returned each time CALL
RANUNI is executed.
The CALL RANUNI routine updates seed and returns a variate x that
is generated from the uniform distribution on the interval (0,1), using a
prime modulus multiplicative generator with modulus 231-1
and multiplier 397204094 (Fishman and Moore 1982) (See References).
By adjusting the seeds, you can force
streams of variates
to agree or disagree for some or all of the observations in the same, or in
subsequent, DATA steps.
For a discussion and example of an effective use of the random number
CALL routines, see Starting, Stopping, and Restarting a Stream.
The CALL RANUNI routine gives greater
control of the seed and random number streams than does the RANUNI function.
This example uses the CALL RANUNI routine:
options pageno=1 nodate ls=80 ps=64;
data u1(keep=x);
seed = 104;
do i = 1 to 5;
call ranuni(seed, x);
output;
end;
call symputx('seed', seed);
run;
data u2(keep=x);
seed = &seed;
do i = 1 to 5;
call ranuni(seed, x);
output;
end;
run;
data all;
set u1 u2;
z = ranuni(104);
run;
proc print label;
label x = 'Separate Streams' z = 'Single Stream';
run;
The following output shows the results:
Output from the CALL RANUNI Routine
The SAS System 1
Separate Single
Obs Streams Stream
1 0.23611 0.23611
2 0.88923 0.88923
3 0.58173 0.58173
4 0.97746 0.97746
5 0.84667 0.84667
6 0.80484 0.80484
7 0.46983 0.46983
8 0.29594 0.29594
9 0.17858 0.17858
10 0.92292 0.92292
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.