Hi all,
I want to generate 10400 random numbers starting at 60000. How can I do that in sas?
Thank you in advance!
Adi
Easily.
But you will need to provide more information.
What does "starting at 60000" mean? That all numbers must be 60,000 or greater? Is 60,000 exactly OK? Does the first number have to be 60,000?
Do all the numbers have to be integers?
Is there a limit to the maximum size of a random number?
Can the same number appear more than once in the series?
Go it.
Thank you all!
Hi Reeza,
Yes, I figured it out as below:
proc plan seed= 12345;
factors BLOCK_NUMBER=16 ordered Block=4 ordered/noprint;
treatments trt =4 random;
output out=step1 trt nvals=(1 1 2 2) ;
run;
quit;
** Kit List Number;
proc sort data=step1; by Block; run;
data step2(keep=BLOCK_NUMBER Kit_List_Number trt);
set step1;
by Block;
Kit_List_Number = _n_+ 10000;
run;
proc sort; by BLOCK_NUMBER; run;
Thanks,
Adi
With a do loop and the RAND() function.
@chinna0369 wrote:
Hi all,
I want to generate 10400 random numbers starting at 60000. How can I do that in sas?
Thank you in advance!
Adi
For a general overivew, see "How to generate random numbers in SAS."
If you want only integers in a certain (such as [60000, 100000]) then see "How to generate random integers in SAS."
I like PROC PLAN as much as the next guy, but are you sure this is the answer to your question? These are not random numbers, they do not start at 60,000 and there are not 10,400 of them. Can you explain why this is the solution?
Hi Reeza,
Yes, I made some changes to my code because I don't want to share my exact code here.
Thanks,
Adi
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.