Language Reference


RANDSEED Call

CALL RANDSEED (seed <, reinit> );

The RANDSEED subroutine sets the initial state for the RANDGEN subroutine and routines that generate random combinations (RANCOMB ), permutations (RANPERK and RANPERM ), and samples (SAMPLE ).

The input arguments to the RANDSEED call are as follows:

seed

is a number to be used to initialize the RANDGEN random number generator.

reinit

specifies whether the random number stream should be reinitialized after the first initialization, within the same PROC IML session.

The RANDSEED subroutine enables you to specify an initial seed for subsequent RANDGEN calls. If the RANDSEED subroutine is not called, or if you specify 0 as a seed, a seed is generated internally. The initial seed is obtained from the Intel RdRand instruction on CPUs that support that instruction, or from the current datetime value otherwise. For more information, see the documentation for the STREAMINIT call in Base SAS.

The RANDSEED routine is used to generate a reproducible stream of pseudorandom numbers. The optional reinit parameter controls whether the random number stream is reinitialized after it has begun generating random numbers. If the second argument is 1, the stream is reinitialized; otherwise subsequent calls to the RANDSEED subroutine are ignored. To ensure that you are working with an independent random number stream within your PROC IML session, set reinit to 0 or do not specify that argument.

In SAS/IML 14.1, a change was made to the initialization of the Mersenne twister (MT) pseudorandom number generator, which is used by the RANDGEN subroutine and by other functions in SAS/IML software. When the seed is exactly divisible by 8192, the MT algorithm uses the 2002 initialization algorithm (Matsumoto and Nishimura 2002). Otherwise, the MT algorithm is initialized by using the 1998 initialization algorithm (Matsumoto and Nishimura 1998). A SAS NOTE appears when the 2002 initialization is used.