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,
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.