/***************************************************************************************************************** SAS file name: random_number.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to generate a random integer between 1 and 10 in SAS Author: Peter Clemmensen Creation Date: 31/10/2020 This program supports the blog post "Generate Random Number Between 1 and 10 in SAS" on SASnrd.com *****************************************************************************************************************/ /* From SAS 9.4M5 */ data _null_; r = rand("integer", 1, 10); /* r = rand("integer", 10); equivalent */ put r; run; /* Before that */ data _null_; r = ceil(rand('uniform')*10); put r=; run; /* Random integer between 5 and 10 */ data _null_; min = 5; max = 10; r = min + floor(rand("uniform") * (1 + max - min)); put r; run; /* Integer limits for the two approaches */ data _null_; r = rand('integer', 2147483647, 2147483647); /* Works */ r = rand('integer', 2147483648, 2147483648); /* Error */ run;