BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chinna0369
Pyrite | Level 9

Hi all, 

 

I want to generate 10400 random numbers starting at 60000. How can I do that in sas?

 

Thank you in advance!

Adi

1 ACCEPTED SOLUTION

Accepted Solutions
chinna0369
Pyrite | Level 9

Go it.

 

Thank you all!

View solution in original post

8 REPLIES 8
Astounding
PROC Star

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?

chinna0369
Pyrite | Level 9

Go it.

 

Thank you all!

Reeza
Super User
Please select the appropriate answer, NOT your answer unless you found the answer yourself or elsewhere and are posting it here.
chinna0369
Pyrite | Level 9

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

Reeza
Super User

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


 

Rick_SAS
SAS Super FREQ

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."

 

Rick_SAS
SAS Super FREQ

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?

chinna0369
Pyrite | Level 9

Hi Reeza, 

 

Yes, I made some changes to my code because I don't want to share my exact code here.

 

Thanks,

Adi

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 8 replies
  • 1243 views
  • 0 likes
  • 4 in conversation