<?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 Having trouble with my do...while statement, I am not sure what I am doing wrong. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278829#M56129</link>
    <description>&lt;P&gt;Hello! I was wondering if anyone knows why y=20.25 shows up in my output data although I specified "while (y&amp;lt;20)." I am not sure what I am doing wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data do_while_data;&lt;BR /&gt;y=0;&lt;BR /&gt;do i= 1 to 5 by 0.5 while (y&amp;lt;20);&lt;BR /&gt;y=i**2; /*values are 1, 2.25, 4, 6.25,...,16*/&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=do_while_data;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my output data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3687i7AB8B779BA3F6E12/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Screen Shot 2016-06-20 at 4.16.58 PM.png" title="Screen Shot 2016-06-20 at 4.16.58 PM.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jun 2016 20:19:48 GMT</pubDate>
    <dc:creator>drajabhathor</dc:creator>
    <dc:date>2016-06-20T20:19:48Z</dc:date>
    <item>
      <title>Having trouble with my do...while statement, I am not sure what I am doing wrong.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278829#M56129</link>
      <description>&lt;P&gt;Hello! I was wondering if anyone knows why y=20.25 shows up in my output data although I specified "while (y&amp;lt;20)." I am not sure what I am doing wrong here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data do_while_data;&lt;BR /&gt;y=0;&lt;BR /&gt;do i= 1 to 5 by 0.5 while (y&amp;lt;20);&lt;BR /&gt;y=i**2; /*values are 1, 2.25, 4, 6.25,...,16*/&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=do_while_data;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my output data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/3687i7AB8B779BA3F6E12/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="Screen Shot 2016-06-20 at 4.16.58 PM.png" title="Screen Shot 2016-06-20 at 4.16.58 PM.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 20:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278829#M56129</guid>
      <dc:creator>drajabhathor</dc:creator>
      <dc:date>2016-06-20T20:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble with my do...while statement, I am not sure what I am doing wrong.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278834#M56130</link>
      <description>&lt;P&gt;You're not doing anything wrong, it's&amp;nbsp;where the WHILE condition is evaluated&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;The expression is evaluated at the top of the loop before the statements in the DO loop are executed. If the expression is true, the DO loop iterates. If the expression is false the first time it is evaluated, the DO loop does not iterate even once.
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p1awxgleif5wlen1pja0nrn6yi6i.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p1awxgleif5wlen1pja0nrn6yi6i.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In your case, when it enters the loop its 16, at the end it's 20.25 so it doesn't iterate again.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 20:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278834#M56130</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-20T20:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble with my do...while statement, I am not sure what I am doing wrong.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278840#M56133</link>
      <description>&lt;P&gt;When SAS hits the DO loop, y is 0.&amp;nbsp; So the WHILE condition is false at that point, and the loop always iterates at least once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After the loop iterates once, it is possible that the WHILE condition becomes false and the loop ends.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2016 21:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Having-trouble-with-my-do-while-statement-I-am-not-sure-what-I/m-p/278840#M56133</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-20T21:17:36Z</dc:date>
    </item>
  </channel>
</rss>

