Data editing > Expressions > Arithmetic expressions > Generating a random number
 
Generating a random number
Quick reference
To generate a random number in the range 1 to n, type:
random(n)
in the edit section.
More information
Quantum can generate random numbers automatically with the random function:
random(n)
where n is the maximum value the random number may take. So, to generate a random number in the range 1 to 100, the expression would read:
random(100)
The number produced may be saved for later use in an integer variable or column, thus:
rnum=random(32)
c(110,112)=random(156)
When using random with columns, make sure that the number of columns allocated to the number is sufficient to store the highest possible number that can be generated. In this example, you need three columns in order to store numbers up to 156.
Note random generates a different random value each time it is run, even on reruns of the same job. If you want to retain the same set of random values between runs, copy them into the data the first time you run the job.
See also
Arithmetic expressions