CALL RANUNI

# CALL RANUNI

Returns a random variate from a uniform distribution

 Category: Random Number

## Syntax

 CALL RANUNI(seed,x);

### Arguments

seed
is the seed value. For more information about seeds, see Seed Values. A new value for seed is returned each time CALL RANUNI is executed.
 Range: seed < 231 - 1 Note If seed 0, the time of day is used to initialize the seed stream.

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.

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 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 RANUNI Example shows the results.

The RANUNI 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```

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.

 Function: