Functions and CALL Routines |
Returns a random variate from a normal distribution.
-
seed
-
is the seed value. A new value for seed is returned each time CALL RANNOR is executed.
-
x
-
is a numeric variable. A new value for
the random variate x is returned each time CALL
RANNOR is executed.
The CALL RANNOR routine updates seed and returns a variate x that
is generated from a normal distribution, with mean 0 and variance 1.
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.
The CALL RANNOR routine uses the Box-Muller transformation
of RANUNI uniform variates.
For a discussion and example of an effective use of the random number
CALL routines, see Starting, Stopping, and Restarting a Stream.
The CALL RANNOR routine gives greater
control of the seed and random number streams than does the RANNOR function.
This example uses the CALL RANNOR routine:
options pageno=1 ls=80 ps=64 nodate;
data u1(keep=x);
seed = 104;
do i = 1 to 5;
call rannor(seed, X);
output;
end;
call symputx('seed', seed);
run;
data u2(keep=x);
seed = &seed;
do i = 1 to 5;
call rannor(seed, X);
output;
end;
run;
data all;
set u1 u2;
z = rannor(104);
run;
proc print label;
label x = 'Separate Streams' z = 'Single Stream';
run;
Output from the CALL RANNOR Routine
The SAS System 1
Separate Single
Obs Streams Stream
1 1.30390 1.30390
2 1.03049 1.03049
3 0.19491 0.19491
4 -0.34987 -0.34987
5 1.64273 1.64273
6 -1.75842 -1.75842
7 0.75080 0.75080
8 0.94375 0.94375
9 0.02436 0.02436
10 -0.97256 -0.97256
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.