turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- What do I have to write inside Ranuni function?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

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

Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-11-2017 03:55 AM

The link below could help you

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001281561.htm#a001...

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001281561.htm#a001...

Thanks,

Jag

Jag

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

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

http://blogs.sas.com/content/iml/2011/08/31/random-number-streams-in-sas-how-do-they-work.html

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-11-2017 08:51 PM

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"