Hi, I have been studying RANUNI function and I don't understand why sometimes people uses it with this expression: int(RANUNI(36830)*n) .
What does the number inside of the function mean and why is it sometimes multiplied with "n"?
Thanks
The number is called the random number seed. The seed value controls the sequence of random numbers. See this article
http://blogs.sas.com/content/iml/2011/08/31/random-number-streams-in-sas-how-do-they-work.html
But you should be aware that the RAND function is the preferred way to generate random numbers. See "Six reasons you should stop using the RANUNI function to generate random numbers" Item #3 addresses your question.
I see that you've already got half your answer .. so here is the other half. The *n is there to get a number between 1 and n.
A more general way to specify it is: x=min + floor((1 + max - min) * rand("uniform"))
That way you can select a random number between min and max.
Also, if you use a seed of zero, SAS will use time of day to select which "table" to use.
Art, CEO, AnalystFinder.com
It looks like you are trying to generate a random integer in the range [a,b].
See the article "How to generate random integers in SAS"
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.