<?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: Difference in output for do untill and do looping. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570528#M160888</link>
    <description>&lt;P&gt;You are going to see a difference starting with the second time through the loop.&lt;/P&gt;
&lt;P&gt;When you use DO UNTIL ( total ge 200) the value of total does not change from the end of one iteration of the loop to the start of the second.&lt;/P&gt;
&lt;P&gt;But when you use DO TOTAL=100 to 200 (note that the increment amount will be 1 since it is not specified) the value of TOTAL is increased by 1 at the start of each new iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 288pt;" border="0" width="384" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" style="height: 14.4pt; width: 48pt;"&gt;Year&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total In&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total Out&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total In&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total Out&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;103.75&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;103.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;STRONG&gt;103.75&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;107.6406&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;STRONG&gt;104.75&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;108.6781&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;107.6406&lt;/TD&gt;
&lt;TD align="right"&gt;111.6771&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;109.6781&lt;/TD&gt;
&lt;TD align="right"&gt;113.7911&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;4&lt;/TD&gt;
&lt;TD align="right"&gt;111.6771&lt;/TD&gt;
&lt;TD align="right"&gt;115.865&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;114.7911&lt;/TD&gt;
&lt;TD align="right"&gt;119.0957&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Tue, 02 Jul 2019 12:49:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-02T12:49:19Z</dc:date>
    <item>
      <title>Difference in output for do untill and do looping.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570469#M160860</link>
      <description>Hi i ran the below codes and they gave me different outputs.i wanted to check how many years it will take for $100 at 3.75% int per annum to double?&lt;BR /&gt;For do:&lt;BR /&gt;Data x;&lt;BR /&gt;Int =0.375;&lt;BR /&gt;Total=100;&lt;BR /&gt;Do total= 100 to 200;&lt;BR /&gt;Year+1;&lt;BR /&gt;Total= total +int*total ;&lt;BR /&gt;Output; end;&lt;BR /&gt;Run; this gave 16 obs&lt;BR /&gt;While same query , changing do statement to do until(total ge 200)&lt;BR /&gt;The result changed to 19 obs.&lt;BR /&gt;&lt;BR /&gt;Can someone explain what is the logic behind it?&lt;BR /&gt;Really appreciate your help.</description>
      <pubDate>Tue, 02 Jul 2019 09:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570469#M160860</guid>
      <dc:creator>ankitasharma</dc:creator>
      <dc:date>2019-07-02T09:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in output for do untill and do looping.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570491#M160874</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/229511"&gt;@ankitasharma&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Only the DO-UNTIL approach is correct (assuming that you mean Int=0.&lt;STRONG&gt;0&lt;/STRONG&gt;375). With the iterative DO loop (&lt;FONT face="courier new,courier"&gt;do Total=100 to 200;&lt;/FONT&gt;) Total is incremented by 1 at the end of each iteration (i.e. after the OUTPUT statement has executed), which is not what you want. You can replicate this behavior (just for demonstration) with the DO-UNTIL approach by inserting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;total+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;between the OUTPUT and END statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Related quote from the help file "DO Statement, Iterative":&lt;/P&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-syntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-otherArgGroup"&gt;
&lt;DIV id="p02so7o86anedyn1wy3a2obvquru" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-caution"&gt;&lt;FONT color="#808080"&gt;&lt;STRONG&gt;CAUTION:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;
&lt;DIV class="xis-caution"&gt;
&lt;DIV class="xis-cautionLeadin"&gt;&lt;STRONG&gt;Avoid changing the index variable within the &lt;FONT&gt;DO&lt;/FONT&gt; group.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 11:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570491#M160874</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-07-02T11:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in output for do untill and do looping.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570528#M160888</link>
      <description>&lt;P&gt;You are going to see a difference starting with the second time through the loop.&lt;/P&gt;
&lt;P&gt;When you use DO UNTIL ( total ge 200) the value of total does not change from the end of one iteration of the loop to the start of the second.&lt;/P&gt;
&lt;P&gt;But when you use DO TOTAL=100 to 200 (note that the increment amount will be 1 since it is not specified) the value of TOTAL is increased by 1 at the start of each new iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 288pt;" border="0" width="384" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" style="height: 14.4pt; width: 48pt;"&gt;Year&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total In&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total Out&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total In&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Total Out&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;103.75&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;100&lt;/TD&gt;
&lt;TD align="right"&gt;103.75&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;2&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;STRONG&gt;103.75&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;107.6406&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;&lt;STRONG&gt;104.75&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD align="right"&gt;108.6781&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;3&lt;/TD&gt;
&lt;TD align="right"&gt;107.6406&lt;/TD&gt;
&lt;TD align="right"&gt;111.6771&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;109.6781&lt;/TD&gt;
&lt;TD align="right"&gt;113.7911&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" style="height: 14.4pt;"&gt;4&lt;/TD&gt;
&lt;TD align="right"&gt;111.6771&lt;/TD&gt;
&lt;TD align="right"&gt;115.865&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;114.7911&lt;/TD&gt;
&lt;TD align="right"&gt;119.0957&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 12:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-in-output-for-do-untill-and-do-looping/m-p/570528#M160888</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-02T12:49:19Z</dc:date>
    </item>
  </channel>
</rss>

