<?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: problem in Do Loop in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/problem-in-Do-Loop/m-p/579820#M13489</link>
    <description>&lt;P&gt;Your use of a do loop is correct, but the sequence of calculations is not. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data deposit;
amount = 7000;
rate = 0.12;
do year = 1 to 15;
  earned = amount * 0.12;
  amount = amount + earned;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BY in a do statement is used to specify an increment other than 1. You can (among others) use to count down:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 15 to 1 by -1;
  put i=;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Aug 2019 08:31:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-08-08T08:31:58Z</dc:date>
    <item>
      <title>problem in Do Loop</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problem-in-Do-Loop/m-p/579818#M13488</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I'm facing problem to understand loops. what is the use of loops or why do we use By increment in&amp;nbsp; Do loop?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(i)&amp;nbsp; I have a dataset which has a value of 7000 and I have to determine the value after 15 years by the constant annual interest rate of 12% and&lt;/P&gt;&lt;P&gt;(ii) compound annual interest rate 12%.&lt;/P&gt;&lt;P&gt;I was trying with this code but I think it's incorrect.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data deposit;&lt;BR /&gt;amount = 7000;&lt;BR /&gt;rate = 0.12;&lt;BR /&gt;do year = 1 to 15;&lt;BR /&gt;amount + earned;&lt;BR /&gt;earned + (amount*0.12);&lt;BR /&gt;principal = amount + earned;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 08:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problem-in-Do-Loop/m-p/579818#M13488</guid>
      <dc:creator>u39734216</dc:creator>
      <dc:date>2019-08-08T08:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: problem in Do Loop</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problem-in-Do-Loop/m-p/579820#M13489</link>
      <description>&lt;P&gt;Your use of a do loop is correct, but the sequence of calculations is not. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data deposit;
amount = 7000;
rate = 0.12;
do year = 1 to 15;
  earned = amount * 0.12;
  amount = amount + earned;
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BY in a do statement is used to specify an increment other than 1. You can (among others) use to count down:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do i = 15 to 1 by -1;
  put i=;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2019 08:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problem-in-Do-Loop/m-p/579820#M13489</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-08T08:31:58Z</dc:date>
    </item>
  </channel>
</rss>

