<?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: Do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394705#M95141</link>
    <description>&lt;P&gt;1) Incomplete data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Iterated do loops: ie. Do var = 1 to value (by otherval)&lt;/P&gt;
&lt;P&gt;always interate until the value limit is exceeded. At which point the the code inside the loop is not executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is similar to Do while (x &amp;lt; 10);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x+1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the condition is true until x is greater than or equal to 10. At which time x is larger than the loop limit, the loop doesn't execute but the value of x is retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2017 15:02:45 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-09-11T15:02:45Z</dc:date>
    <item>
      <title>Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394697#M95137</link>
      <description>&lt;P&gt;The following SAS program is submitted: data WORK.LOOP;&lt;/P&gt;&lt;P&gt;X = 0;&lt;/P&gt;&lt;P&gt;do Index = 1 to 5 by 2;&lt;/P&gt;&lt;P&gt;X = Index; end; run;&lt;/P&gt;&lt;P&gt;Upon completion of execution, what are the values of the variables X and Index in the SAS data set named WORK.LOOP?&lt;/P&gt;&lt;P&gt;A. X = 3, Index = 5&lt;/P&gt;&lt;P&gt;B. X = 5, Index = 5&lt;/P&gt;&lt;P&gt;C. X = 5, Index = 6&lt;/P&gt;&lt;P&gt;D. X = 5, Index = 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the correct_answer = "D"?? I thought index should never exceed 5?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 14:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394697#M95137</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-11T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394702#M95139</link>
      <description>&lt;P&gt;Just the opposite ... the final value of INDEX will always exceed 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key issue is how INDEX gets incremented.&amp;nbsp; Each time the loop reaches the END statement, it adds 2 to the value of INDEX.&amp;nbsp; Then it considers, "Am I done yet?"&amp;nbsp; The criterion that it uses to determine whether the loop is done:&amp;nbsp; does INDEX now exceed the upper bound of 5.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 15:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394702#M95139</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-11T15:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394704#M95140</link>
      <description>&lt;P&gt;This looks a lot like homework &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; but still....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this form of the Do statement execution of the step continues until the value of the&amp;nbsp;index &lt;STRONG&gt;exceeds&lt;/STRONG&gt; the stop value - you can find more here&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201276.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000201276.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 15:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394704#M95140</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-11T15:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394705#M95141</link>
      <description>&lt;P&gt;1) Incomplete data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Iterated do loops: ie. Do var = 1 to value (by otherval)&lt;/P&gt;
&lt;P&gt;always interate until the value limit is exceeded. At which point the the code inside the loop is not executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is similar to Do while (x &amp;lt; 10);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x+1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the condition is true until x is greater than or equal to 10. At which time x is larger than the loop limit, the loop doesn't execute but the value of x is retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 15:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394705#M95141</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-11T15:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394708#M95143</link>
      <description>&lt;P&gt;Oh so it means if X=1, index=3, X=3, index=5, X=5,index=7? Sorry just started learning SAS, pardon if I am weak at my foundation, thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 15:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394708#M95143</guid>
      <dc:creator>pchen002</dc:creator>
      <dc:date>2017-09-11T15:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394711#M95144</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; At the end of the third iteration, once X=7, SAS notices that 7 &amp;gt; 5 so the loop must be complete.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 15:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop/m-p/394711#M95144</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-11T15:14:52Z</dc:date>
    </item>
  </channel>
</rss>

