<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: RANUNI function assigns the same number to 90% of records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696573#M212792</link>
    <description>&lt;P&gt;It looks like you're specifying a seed value of -1, which uses the time of day to initialize the seed stream. I don't know how you're using the RANUNI function to generate the list of random numbers, but if (?) you're including the function in a loop, it's possible that this runs faster than the clock updates -- and therefore reuses the same seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, see&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html" target="_self"&gt;How to Generate Random Numbers in SAS&lt;/A&gt;&amp;nbsp;by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Nov 2020 16:17:20 GMT</pubDate>
    <dc:creator>Watts</dc:creator>
    <dc:date>2020-11-04T16:17:20Z</dc:date>
    <item>
      <title>RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696197#M212615</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;I am hoping someone has come across this issue previously and knows why it happens: I am assigning a random number between 1 and 1,000 to a daily feed of data by making use of the RANUNI function:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAS_RANDOM_NUMBER&amp;nbsp; = int(1000*ranuni(-1));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The problem I have is that on certain days the same number is allocated to 90% of the records, so not so random after all. Has anyone ever come across this problem?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 13:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696197#M212615</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2020-11-03T13:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696199#M212616</link>
      <description>&lt;P&gt;Try using the Rand Function instead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rick Wicklin explains why in the article&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni.html" target="_self"&gt;Six reasons you should stop using the RANUNI function to generate random numbers&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 13:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696199#M212616</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-03T13:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696200#M212617</link>
      <description>&lt;P&gt;Don't use RANUNI, use the improved RAND:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call streaminit(-1);
SAS_RANDOM_NUMBER  = int(1000*rand('uniform'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want a uniform integer distribution, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rand('integer',1000);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Nov 2020 13:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696200#M212617</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-03T13:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696406#M212706</link>
      <description>&lt;P&gt;Thanks guys! Will that explain why more than 90% of the records get the same number assigned though? Is RANUNI that "bad"?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 06:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696406#M212706</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2020-11-04T06:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696425#M212715</link>
      <description>&lt;P&gt;Well, I never experienced something as egregious as what you describe, but then I rarely needed random numbers. I do mostly ETL work, no simulations.&lt;/P&gt;
&lt;P&gt;And I've been using RAND since it was introduced.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 09:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696425#M212715</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-04T09:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696573#M212792</link>
      <description>&lt;P&gt;It looks like you're specifying a seed value of -1, which uses the time of day to initialize the seed stream. I don't know how you're using the RANUNI function to generate the list of random numbers, but if (?) you're including the function in a loop, it's possible that this runs faster than the clock updates -- and therefore reuses the same seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, see&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html" target="_self"&gt;How to Generate Random Numbers in SAS&lt;/A&gt;&amp;nbsp;by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696573#M212792</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-11-04T16:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: RANUNI function assigns the same number to 90% of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696574#M212793</link>
      <description>&lt;P&gt;If you post the code you are using, we can say more about what you are seeing and why.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 16:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/RANUNI-function-assigns-the-same-number-to-90-of-records/m-p/696574#M212793</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-11-04T16:25:57Z</dc:date>
    </item>
  </channel>
</rss>

