<?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: Count a value _ Conditional loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413760#M279965</link>
    <description>&lt;P&gt;Sorry I thought I made it clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how many iterations it will take. I just want it to stop once ANY number is drawn 3 times. not randomly generate 3 numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, 1, 2, 3&amp;nbsp;&amp;nbsp;&amp;nbsp; continue loop because no number is generated for 3 times.&lt;/P&gt;&lt;P&gt;1, 2, 3, 1, 2, 3,&amp;nbsp; continue loop because no number is generated for 3 times.&lt;/P&gt;&lt;P&gt;1, 2, 3, 1, 2, 3,1, leave because number 1 is drawn 3 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only chance it takes 20 iterations is each number (from 1 to 10) is generated 2 times. And then for the 21st iteration no matter which number it generates it will be the 3rd appearance so exit the loop. That's why I set the loop at 20 iterations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 18:11:30 GMT</pubDate>
    <dc:creator>EvanM</dc:creator>
    <dc:date>2017-11-15T18:11:30Z</dc:date>
    <item>
      <title>Count a value _ Conditional loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413732#M279962</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have got the following code to generate 20 random integers between 1 and 10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Unif(keep=u x);&lt;BR /&gt;call streaminit(123);&lt;BR /&gt;do i = 1 to 20;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; u = rand("Uniform");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; x = ceil( 10*u );&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is that, once a number is generated for the 3rd time, leave the loop and output the numbers generated.&lt;/P&gt;&lt;P&gt;Any suggestions on how to realize the function? Thanks in advance.&lt;/P&gt;&lt;P&gt;I am using Enterprise Guide 7.12 btw.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 16:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413732#M279962</guid>
      <dc:creator>EvanM</dc:creator>
      <dc:date>2017-11-15T16:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count a value _ Conditional loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413738#M279963</link>
      <description>&lt;P&gt;Its not clear to me why.&amp;nbsp; If you only want 3 iterations then set the do loop to maximum 3 iterations.&amp;nbsp; You can control the loop with:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/03/15/leave-continue-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/03/15/leave-continue-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However why, if you know how many iterations, just fix it?&amp;nbsp; To me, I can't see a reason to ever use these, as they effectively obfuscate the code around them.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413738#M279963</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-15T17:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Count a value _ Conditional loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413739#M279964</link>
      <description>&lt;P&gt;You may need to clarify the requirement.&lt;/P&gt;
&lt;P&gt;This will stop on the first value of X repeated 3 times.&lt;/P&gt;
&lt;PRE&gt;data Unif(keep=u x);
   call streaminit(123);
   array t {10} _temporary_ (0,0,0,0,0,0,0,0,0,0) ;
   do while (1=1);
      u = rand("Uniform");            
      x = ceil( 10*u );
      t[x]= t[x]+1;
      output;
      if t[x]=3 then leave;
   end;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Nov 2017 17:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413739#M279964</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-15T17:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Count a value _ Conditional loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413760#M279965</link>
      <description>&lt;P&gt;Sorry I thought I made it clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know how many iterations it will take. I just want it to stop once ANY number is drawn 3 times. not randomly generate 3 numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, 1, 2, 3&amp;nbsp;&amp;nbsp;&amp;nbsp; continue loop because no number is generated for 3 times.&lt;/P&gt;&lt;P&gt;1, 2, 3, 1, 2, 3,&amp;nbsp; continue loop because no number is generated for 3 times.&lt;/P&gt;&lt;P&gt;1, 2, 3, 1, 2, 3,1, leave because number 1 is drawn 3 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only chance it takes 20 iterations is each number (from 1 to 10) is generated 2 times. And then for the 21st iteration no matter which number it generates it will be the 3rd appearance so exit the loop. That's why I set the loop at 20 iterations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 18:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413760#M279965</guid>
      <dc:creator>EvanM</dc:creator>
      <dc:date>2017-11-15T18:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count a value _ Conditional loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413761#M279966</link>
      <description>&lt;P&gt;Cool ! Appreciate it !&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 18:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-a-value-Conditional-loop/m-p/413761#M279966</guid>
      <dc:creator>EvanM</dc:creator>
      <dc:date>2017-11-15T18:13:33Z</dc:date>
    </item>
  </channel>
</rss>

