Chapter Contents |
Previous |
Next |
CALL RANNOR |
Category: | Random Number |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
See Also |
Syntax |
CALL RANNOR(seed,x); |
Range: | seed < 231 - 1 |
Note: | If seed 0, the time of day is used to initialize the seed stream. |
Details |
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.
Comparisons |
The CALL RANNOR routine gives greater control of the seed and random number streams than does the RANNOR function.
Examples |
This example uses the CALL RANNOR routine:
options nodate pageno=1 linesize=80 pagesize=60; data case; retain Seed_1 Seed_2 Seed_3 45; do i=1 to 10; call rannor(Seed_1,X1); call rannor(Seed_2,X2); X3=rannor(Seed_3); if i=5 then do; Seed_2=18; Seed_3=18; end; output; end; run; proc print; id i; var Seed_1-Seed_3 X1-X3; run;
The RANNOR Example shows the results.
The SAS System 1 i Seed_1 Seed_2 Seed_3 X1 X2 X3 1 1404437564 1404437564 45 -0.85252 -0.85252 -0.85252 2 1445125588 1445125588 45 -0.05865 -0.05865 -0.05865 3 1326029789 1326029789 45 -0.90628 -0.90628 -0.90628 4 1988843719 1988843719 45 1.15526 1.15526 1.15526 5 2137808851 18 18 1.68697 1.68697 1.68697 6 1233028129 991271755 18 -0.47276 -1.44726 -0.47276 7 50049159 1437043694 18 1.33423 -0.87677 1.33423 8 802575599 959908645 18 -1.63511 -0.97261 -1.63511 9 100573943 1225034217 18 1.55410 -0.64742 1.55410 10 414117170 425626811 18 0.10736 0.14963 0.10736 |
Changing Seed_2 for the CALL RANNOR statement, when I=5, forces the stream of the variates for X2 to deviate from the stream of the variates for X1. Changing Seed_3 on the RANNOR function, however, has no effect.
See Also |
Function:
|
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.