<?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 ( ) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75957#M22048</link>
    <description>To me the RANTBL function makes this much easier.   &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data BB;&lt;BR /&gt;
   /*set AA;*/&lt;BR /&gt;
   do id = 1 to 100;&lt;BR /&gt;
      *ran1=ranuni(1234);&lt;BR /&gt;
      *if ran1 &amp;lt; 0.50 then test_cell = 'PM400';&lt;BR /&gt;
      *else if ran1 &amp;gt;= 0.50 then test_cell = 'PM401'; &lt;BR /&gt;
&lt;BR /&gt;
      ran1 = rantbl(1234,.5);&lt;BR /&gt;
      length test_cell $5;&lt;BR /&gt;
      test_cell = scan('PM400 PM401',ran1);&lt;BR /&gt;
      output;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
Proc Freq data = BB; tables test_cell;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Thu, 15 Oct 2009 14:49:29 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2009-10-15T14:49:29Z</dc:date>
    <item>
      <title>Ranuni ( )</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75954#M22045</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I hope I posted this in the right forum.  I am trying to figure out how RANUNI works in the following pgm.&lt;BR /&gt;
&lt;BR /&gt;
Data BB (drop=ran1);&lt;BR /&gt;
set AA;&lt;BR /&gt;
ran1=ranuni(1234);&lt;BR /&gt;
   if ran1 &amp;lt; 0.50 then do;&lt;BR /&gt;
      test_cell = 'PM400';&lt;BR /&gt;
   end;&lt;BR /&gt;
&lt;BR /&gt;
   else if ran1 &amp;gt;= 0.50 then do;&lt;BR /&gt;
      test_cell = 'PM401'; &lt;BR /&gt;
   end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Proc Freq data = BB; tables test_cell;&lt;BR /&gt;
&lt;BR /&gt;
** here is the part of the output that I dont understand*****&lt;BR /&gt;
&lt;BR /&gt;
test_cell    frequency      percent&lt;BR /&gt;
------------------------------------------------&lt;BR /&gt;
PM400      4194             50.65&lt;BR /&gt;
PM401      4087             49.35&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I understand RANUNI assignes a random number to a variable, in this case 'ran1'.  But how does the value of 'ran1' control what records get what test_cell?&lt;BR /&gt;
&lt;BR /&gt;
Thank you so much for any input !</description>
      <pubDate>Thu, 15 Oct 2009 13:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75954#M22045</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2009-10-15T13:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Ranuni ( )</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75955#M22046</link>
      <description>let me rephrase my question a little:&lt;BR /&gt;
&lt;BR /&gt;
according to the result (50.65% vs 49.35%) I can see that the value of 'ran1' was evenly distributed between &amp;lt; 0.50 and &amp;gt;= 0.50.  Why is that?  Is this by design? &lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Thu, 15 Oct 2009 13:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75955#M22046</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2009-10-15T13:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Ranuni ( )</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75956#M22047</link>
      <description>Yes, it is by design.  RANUNI() is one of many pseudo random number generators in SAS.  In particular, RANUNI is designed to generate pseudo random numbers on the real line between 0 and 1 with a uniform distribution.&lt;BR /&gt;
&lt;BR /&gt;
From the 9.1.3 documentaiton, "The RANUNI function returns a number that is generated from the uniform distribution on the interval (0,1) using a prime modulus multiplicative generator with modulus 231- and multiplier 397204094 (Fishman and Moore 1982) (See References)."</description>
      <pubDate>Thu, 15 Oct 2009 14:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75956#M22047</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-10-15T14:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Ranuni ( )</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75957#M22048</link>
      <description>To me the RANTBL function makes this much easier.   &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Data BB;&lt;BR /&gt;
   /*set AA;*/&lt;BR /&gt;
   do id = 1 to 100;&lt;BR /&gt;
      *ran1=ranuni(1234);&lt;BR /&gt;
      *if ran1 &amp;lt; 0.50 then test_cell = 'PM400';&lt;BR /&gt;
      *else if ran1 &amp;gt;= 0.50 then test_cell = 'PM401'; &lt;BR /&gt;
&lt;BR /&gt;
      ran1 = rantbl(1234,.5);&lt;BR /&gt;
      length test_cell $5;&lt;BR /&gt;
      test_cell = scan('PM400 PM401',ran1);&lt;BR /&gt;
      output;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
Proc Freq data = BB; tables test_cell;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 15 Oct 2009 14:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75957#M22048</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-10-15T14:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Ranuni ( )</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75958#M22049</link>
      <description>Thank you both for your input !</description>
      <pubDate>Thu, 15 Oct 2009 15:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Ranuni/m-p/75958#M22049</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2009-10-15T15:20:03Z</dc:date>
    </item>
  </channel>
</rss>

