Why the ranuni Function generate the random numbers is not effect.Such as
data aa;
set sashelp.class;
y=ranuni(10);
run;
Why run the code twice ,but the result is sample.
I want to know how to use the sas to generate the random numbers 1 to 9.
as the programming of the python has random function to generate.
Hi @shursulei2
In the code below , The RAND function returns a random uniformly distributed number in the interval (0,1). It is then multiplied by 9 auto output a random integer in the range 1 to 9. NB: The CEILZ function returns the smallest integer that is greater than or equal to the argument.
Is it what you are looking for?
y= ceilz(9*rand('uniform'));
Example:
data aa;
do i=1 to 100000000;
y= ceilz(9*rand('uniform'));
output;
end;
run;
proc freq;
table y;
run;
Best,
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.