<?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: trying to understand RANUNI in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821359#M324271</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183704"&gt;@Santt0sh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; to change in virtually every run of the program, you can use the seed 0, i.e.,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;n = ranuni(&lt;STRONG&gt;0&lt;/STRONG&gt;)&lt;/FONT&gt;. Then "the&amp;nbsp;&lt;SPAN&gt;time of day is used to initialize the seed stream" (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1fkiqt9ygapyxn1pd1w8manlpub.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;), hence the automatic change.&amp;nbsp;&lt;/SPAN&gt;From the resulting random numbers (if you do &lt;EM&gt;not&lt;/EM&gt; drop &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; from dataset RF2) you can even &lt;A href="https://communities.sas.com/t5/SAS-Programming/Getting-Seed-value-used-by-SAS/m-p/809383/highlight/true#M319183" target="_blank" rel="noopener"&gt;determine a non-zero seed&lt;/A&gt; that can be used to reproduce the same results, if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(See also:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni.html" target="_blank" rel="noopener"&gt;Six reasons you should stop using the RANUNI function to generate random numbers&lt;/A&gt;.)&lt;/P&gt;</description>
    <pubDate>Sat, 02 Jul 2022 09:17:21 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-07-02T09:17:21Z</dc:date>
    <item>
      <title>trying to understand RANUNI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821343#M324261</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand the RANUNI function. Trying to create a dataset using RANUNI&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Ex. I have a Dataset ACCOUNTS having the below-mentioned variables&lt;/P&gt;&lt;P&gt;ACCT_NUM, AFLAG RF1, RF2, RF3, RF4 rf2cnts&lt;/P&gt;&lt;P&gt;0000000001&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;0000000004&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;0000000005&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp;&lt;/P&gt;&lt;P&gt;000000300&amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the below code to get a size and assign 1 rf2,rf3, and rf4 respectively if the value is 1&amp;nbsp; in a new variable (for eg. rfn)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data rf2 (drop = x n);

set accounts;

n = ranuni(5);

retain x 1;

if rfcnts eq 1 and x = 10 then do;&amp;nbsp;&amp;nbsp;* x = 10 number of rf2 needed with 1;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rf2f = 1;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x+1;

end;

else do;

&amp;nbsp; &amp;nbsp;rf2f = 0;

end;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to understand when I run the same data step on the same dataset will the value of N change, have tried running the data step on the same dataset a couple of times but every 10-15 mins I still see the value of N is same. is this how it should be or change every time I run the data step with RANUNI in it and on the same dataset with the same values and size?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly note I don't want to use SurveySelect, please see the output attached where we have unchanged values of N.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 23:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821343#M324261</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-07-01T23:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: trying to understand RANUNI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821345#M324262</link>
      <description>&lt;P&gt;If you run the data step using the same SEED you should get the set series of random numbers.&lt;/P&gt;
&lt;P&gt;If that is not what you want then use a different SEED value for each run.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2022 00:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821345#M324262</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-02T00:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: trying to understand RANUNI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821359#M324271</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183704"&gt;@Santt0sh&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; to change in virtually every run of the program, you can use the seed 0, i.e.,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;n = ranuni(&lt;STRONG&gt;0&lt;/STRONG&gt;)&lt;/FONT&gt;. Then "the&amp;nbsp;&lt;SPAN&gt;time of day is used to initialize the seed stream" (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p1fkiqt9ygapyxn1pd1w8manlpub.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;), hence the automatic change.&amp;nbsp;&lt;/SPAN&gt;From the resulting random numbers (if you do &lt;EM&gt;not&lt;/EM&gt; drop &lt;FONT face="courier new,courier"&gt;n&lt;/FONT&gt; from dataset RF2) you can even &lt;A href="https://communities.sas.com/t5/SAS-Programming/Getting-Seed-value-used-by-SAS/m-p/809383/highlight/true#M319183" target="_blank" rel="noopener"&gt;determine a non-zero seed&lt;/A&gt; that can be used to reproduce the same results, if needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(See also:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2013/07/10/stop-using-ranuni.html" target="_blank" rel="noopener"&gt;Six reasons you should stop using the RANUNI function to generate random numbers&lt;/A&gt;.)&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2022 09:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821359#M324271</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-02T09:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: trying to understand RANUNI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821640#M324390</link>
      <description>Thank You for your quick response and this was helpful.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Jul 2022 16:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-understand-RANUNI/m-p/821640#M324390</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-07-05T16:04:26Z</dc:date>
    </item>
  </channel>
</rss>

