06-11-2017 03:11 AM
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"?
06-11-2017 03:55 AM
The number is called the random number seed. The seed value controls the sequence of random numbers. See this article
06-11-2017 06:56 AM
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.
06-11-2017 09:01 AM
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