<?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: Random selection of 1 from 2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694956#M211999</link>
    <description>&lt;P&gt;SAS provides pseudo-random number generating functions. These functions can be set to start the random number sequence at a given point, determined by a &lt;EM&gt;seed&lt;/EM&gt; value. For example the program&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data eyes;
call streaminit(852559); /* Set the random number generation seed */
set sashelp.class;
selectedEye = rand("integer", 2); /* Generate a random number */
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should give you this same pseudo-random sequence :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 321px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51174i8078C2431537CB70/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Oct 2020 17:33:13 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-10-28T17:33:13Z</dc:date>
    <item>
      <title>Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694938#M211992</link>
      <description>&lt;P&gt;&lt;FONT face="andale mono,times" size="4"&gt;Dear All,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times" size="4"&gt;I have one question on random selection of 1 from 2.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times" size="4"&gt;Let say a person has 2 eyes and we randomly select only one eye i.e. either left or right.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times" size="4"&gt;Are we actually able to get the same eye for everyone every time we run our program?&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="andale mono,times" size="4"&gt;Apologies that it's not SAS-related.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 16:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694938#M211992</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2020-10-28T16:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694950#M211997</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16719"&gt;@Miracle&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It depends on whether you specify a positive random seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
call streaminit(27182818);
set sashelp.class;
length random_eye $5;
random_eye=choosec(rand('table',0.5),'left','right');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks to the CALL STREAMINIT statement with a positive argument, the 19 assignments to variable &lt;FONT face="courier new,courier"&gt;random_eye&lt;/FONT&gt; will be the same every time you run the program. Change the argument to a different positive value (e.g., 1) and you'll get (in general) a different, but again stable set of assignments. Without the CALL STREAMINIT statement or using 0 as its argument the assignments will (in general) change from run to run.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 17:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694950#M211997</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-10-28T17:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694956#M211999</link>
      <description>&lt;P&gt;SAS provides pseudo-random number generating functions. These functions can be set to start the random number sequence at a given point, determined by a &lt;EM&gt;seed&lt;/EM&gt; value. For example the program&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data eyes;
call streaminit(852559); /* Set the random number generation seed */
set sashelp.class;
selectedEye = rand("integer", 2); /* Generate a random number */
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should give you this same pseudo-random sequence :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 321px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51174i8078C2431537CB70/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 17:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/694956#M211999</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-10-28T17:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695056#M212046</link>
      <description>&lt;P&gt;If I recall correctly, the ability to duplicate the random number stream is somewhat software and hardware dependent. If you run the code on a different version of SAS, or on a machine with a different math co-processor the results&amp;nbsp;&lt;STRONG&gt;may&amp;nbsp;&lt;/STRONG&gt;differ.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 22:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695056#M212046</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-28T22:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695144#M212075</link>
      <description>&lt;P&gt;Calling &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 12:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695144#M212075</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-10-29T12:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Random selection of 1 from 2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695167#M212093</link>
      <description>&lt;P&gt;Thank you all for your response&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;.&lt;BR /&gt;I have used the call streaminit and it gives me the same eye all the time.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 13:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-selection-of-1-from-2/m-p/695167#M212093</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2020-10-29T13:17:14Z</dc:date>
    </item>
  </channel>
</rss>

