<?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: assign random numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/486391#M126549</link>
    <description>&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;data r ;                             
  set s ;                   
  random = rand ("table",0.5,0.5) ;
run ; &lt;/PRE&gt;
&lt;P&gt;Rand table is good for generating integers with known probabilities. The above results in 1 or 2 with probabilities of 0.5 and 0.5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted a different distribution such as 60% 1 and 40% 2 then&lt;/P&gt;
&lt;PRE&gt;data r ;                             
  set s ;                   
  random = (rand ("table",0.6,0.4) ;
run ; &lt;/PRE&gt;
&lt;P&gt;You can use any number of probabilities as long as they total to 1 though for values with repeating decimals such as 1/3 using a variable or the calculation in the table options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;random = rand ("table",1/3,1/3,1/3) ;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Aug 2018 15:37:51 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-08-13T15:37:51Z</dc:date>
    <item>
      <title>assign random numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/485998#M126346</link>
      <description>&lt;P&gt;data s ;&lt;BR /&gt;input name $ 15. ;&lt;/P&gt;&lt;P&gt;cards ;&lt;BR /&gt;dfsdfdas&lt;BR /&gt;dfsdfasdf&lt;BR /&gt;sdfwtrw&lt;BR /&gt;ghjghj&lt;BR /&gt;fghfdh&lt;BR /&gt;etwrt&lt;BR /&gt;rtyurtuy&lt;BR /&gt;rtrt&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t;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;rtrt&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;rtrysrt&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;rtrrt&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sat, 11 Aug 2018 02:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/485998#M126346</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-11T02:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: assign random numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/486004#M126348</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I fail to observe any "randomness" in your assigned numbers. You merely assign 1 and 2 to the records whose observation numbers are odd and even, respectively. All you need to do to achieve that is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data r ;                  
  set s ;        
  random = 2 - mod (_n_, 2) ;
run ;                        &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, if you really need RANDOM to be random in the [1:2] range, it should instead be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data r ;                             
  set s ;                   
  random = ceil (rand ("uniform") * 2) ;
run ;                                   &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Aug 2018 03:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/486004#M126348</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-08-11T03:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: assign random numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/486391#M126549</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;data r ;                             
  set s ;                   
  random = rand ("table",0.5,0.5) ;
run ; &lt;/PRE&gt;
&lt;P&gt;Rand table is good for generating integers with known probabilities. The above results in 1 or 2 with probabilities of 0.5 and 0.5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted a different distribution such as 60% 1 and 40% 2 then&lt;/P&gt;
&lt;PRE&gt;data r ;                             
  set s ;                   
  random = (rand ("table",0.6,0.4) ;
run ; &lt;/PRE&gt;
&lt;P&gt;You can use any number of probabilities as long as they total to 1 though for values with repeating decimals such as 1/3 using a variable or the calculation in the table options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;random = rand ("table",1/3,1/3,1/3) ;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Aug 2018 15:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-random-numbers/m-p/486391#M126549</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-13T15:37:51Z</dc:date>
    </item>
  </channel>
</rss>

