CALL RANNOR Routine


Returns a random variate from a normal distribution

Category: Random Number

Syntax

CALL RANNOR ( seed,x );

Arguments

seed

  • is the seed value. A new value for seed is returned each time CALL RANNOR is executed.

  • Range: seed < 2 31 -1

  • Note: If seed 0, the time of day is used to initialize the seed stream.

  • See: 'Seed Values' on page 257 for more information about seed values

x

  • is a numeric variable. A new value for the random variate x is returned each time CALL RANNOR is executed.

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 following output shows the results:

Output 4.10: The RANNOR Example
start example
 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 
end example
 

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:

  • 'RANNOR Function' on page 780




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net