PRDNOR and PRDUNI: Generating Reproducible Random Numbers

How to:

Available Languages: reporting, Maintain

The PRDNOR and PRDUNI functions generate reproducible random numbers:

Syntax: How to Generate Reproducible Random Numbers

{PRDNOR|PRDUNI}(seed, output)

where:

PRDNOR

Generates reproducible double-precision random numbers normally distributed with an arithmetic mean of 0 and a standard deviation of 1.

PRDUNI

Generates reproducible double-precision random numbers uniformly distributed between 0 and 1.

seed

Numeric

Is the seed or the field that contains the seed, up to 9 digits. The seed is truncated to an integer.

On z/OS, the numbers do not reproduce.

output

Double-precision

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Generating Reproducible Random Numbers

PRDNOR assigns random numbers and stores them in RAND. These values are then used to randomly pick five employee records identified by the values in the LAST NAME and FIRST NAME fields. The seed is 40. To produce a different set of numbers, change the seed.

DEFINE FILE EMPLOYEE
RAND/D12.2 WITH LAST_NAME = PRDNOR(40, RAND);END
TABLE FILE EMPLOYEE
PRINT LAST_NAME AND FIRST_NAME
BY HIGHEST 5 RAND
END

The output is:

RAND  LAST_NAME        FIRST_NAME 
----  ---------        ---------- 
1.38  STEVENS          ALFRED 
1.12  MCCOY            JOHN 
 .55  SMITH            RICHARD 
 .21  JONES            DIANE 
 .01  IRVING           JOAN