<?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 Do loop until end? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459570#M116740</link>
    <description>&lt;P&gt;I am new to sas. I am trying to run following code. It runs for ever. What am I doing wrong? I am tryting to see how many years it takes to payback loan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data loan;
	initial_payment=1000;
	loan=30000-initial_payment;
	payment=500;
	years=0;

	do until (loan_end=0);
		years+1;
		loan_end=loan-payment;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#442db3" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 08:53:42 GMT</pubDate>
    <dc:creator>Myurathan</dc:creator>
    <dc:date>2018-05-03T08:53:42Z</dc:date>
    <item>
      <title>Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459570#M116740</link>
      <description>&lt;P&gt;I am new to sas. I am trying to run following code. It runs for ever. What am I doing wrong? I am tryting to see how many years it takes to payback loan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data loan;
	initial_payment=1000;
	loan=30000-initial_payment;
	payment=500;
	years=0;

	do until (loan_end=0);
		years+1;
		loan_end=loan-payment;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#442db3" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 08:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459570#M116740</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-05-03T08:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459574#M116742</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data loan;
	initial_payment=1000;
	loan=30000-initial_payment;
	payment=500;
	years=0;

	do until (loan_end LE 0);
		years+1;
		loan_end=loan-payment;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 08:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459574#M116742</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-05-03T08:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459575#M116743</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;. but it also runs forever. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Thu, 03 May 2018 09:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459575#M116743</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-05-03T09:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459580#M116746</link>
      <description>&lt;P&gt;Why do you need the loop, it is a simple calculation:&lt;/P&gt;
&lt;PRE&gt;data loan;
   initial_payment=1000;
   loan=30000-initial_payment;
   payment=500;
   years=loan / payment;
run;&lt;/PRE&gt;
&lt;P&gt;As for why it does not work, well, your condition loan_end le 0 must never be true.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 09:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459580#M116746</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-03T09:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459581#M116747</link>
      <description>Thanks RW9. I am aware that it is a simple calulation. I am trying to learn looping. Can you please explain why loan_end le 0 never be true?. Thanks</description>
      <pubDate>Thu, 03 May 2018 09:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459581#M116747</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-05-03T09:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459585#M116749</link>
      <description>&lt;P&gt;In&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;'s example the value of loan_end is always loan-payment, 28500, hence it never lowers down to 0 or less.&amp;nbsp; Update this to :&lt;/P&gt;
&lt;PRE&gt;data loan;
   initial_payment=1000;
   loan=30000-initial_payment;
   payment=500;
   years=0;
   loan_end=loan;
   do until (loan_end le 0);
      years+1;
      loan_end=loan_end-payment;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;So we set loan_end to be loan, then take payment off loan_end each time, so loan_end goes down&amp;nbsp; We could alos write it as:&lt;/P&gt;
&lt;PRE&gt;data loan;
   initial_payment=1000;
   loan=30000-initial_payment;
   payment=500;
   years=0;
   do until (loan le 0);
      years+1;
      loan=loan-payment;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;Basically you need to ensure the condition in the until is triggered, which as it was being created each round never happened.&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 09:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459585#M116749</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-03T09:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop until end?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459588#M116752</link>
      <description>Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;</description>
      <pubDate>Thu, 03 May 2018 09:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-until-end/m-p/459588#M116752</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-05-03T09:34:41Z</dc:date>
    </item>
  </channel>
</rss>

