CALL RANUNI Routine


Returns a random variate from a uniform distribution

Category: Random Number

Syntax

CALL RANUNI ( seed,x );

Arguments

seed

  • is the seed value. A new value for seed is returned each time CALL RANUNI 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 RANUNI is executed.

Details

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 2 31 -1 and multiplier 397204094 (Fishman and Moore 1982) (See 'References' on page 926).

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.

Comparisons

The CALL RANUNI routine gives greater control of the seed and random number streams than does the RANUNI function.

Examples

This example uses the CALL RANUNI 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 ranuni(Seed_1,X1);        call ranuni(Seed_2,X2);        X3=ranuni(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.14: The RANUNI Example
start example
 The SAS System                                    1    i       Seed_1            Seed_2    Seed_3        X1            X2             X3    1      694315054       694315054      45       0.32332       0.32332       0.32332    2     1404437564      1404437564      45       0.65399       0.65399       0.65399    3     2130505156      2130505156      45       0.99209       0.99209       0.99209    4     1445125588      1445125588      45       0.67294       0.67294       0.67294    5     1013861398              18      18       0.47212       0.47212       0.47212    6     1326029789       707222751      18       0.61748       0.32933       0.61748    7      932142747       991271755      18       0.43406       0.46160       0.43406    8     1988843719       422705333      18       0.92613       0.19684       0.92613    9      516966271      1437043694      18       0.24073       0.66918       0.24073   10     2137808851      1264538018      18       0.99549       0.58885       0.99549 
end example
 

Changing Seed_2 for the CALL RANUNI 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 RANUNI function, however, has no effect.

See Also

Function:

  • 'RANUNI Function' on page 784




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