New User
Posts: 1

# What do I have to write inside Ranuni function?

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

Posts: 1,147

PROC Star
Posts: 1,283

## Re: What do I have to write inside Ranuni function?

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

SAS Super FREQ
Posts: 4,241

## Re: What do I have to write inside Ranuni function?

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.

PROC Star
Posts: 8,164

## Re: What do I have to write inside Ranuni function?

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

SAS Super FREQ
Posts: 4,241

## Re: What do I have to write inside Ranuni function?

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"

Discussion stats
• 5 replies
• 226 views
• 3 likes
• 5 in conversation