<?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: Loan amortization problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581965#M165458</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21164"&gt;@greg6363&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Though you don't have PROC LOAN licensed, Base SAS sports no fewer than 32 various financial functions, among which I'm sure you'll find what you need without having to reinvent the wheel. In your particular case, for example, you may want to take a look at the MORT (i.e. "mortgage") function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
    <pubDate>Sat, 17 Aug 2019 19:41:23 GMT</pubDate>
    <dc:creator>hashman</dc:creator>
    <dc:date>2019-08-17T19:41:23Z</dc:date>
    <item>
      <title>Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581899#M165427</link>
      <description>&lt;P&gt;Unfortunately, my SAS license does not include PROC LOAN which would solve my dilemma so I have to create a loan amortization schedule manually.&amp;nbsp; The following code attempts to utilize the loan information (APR, Payment Frequency, Loan Amount) from the sample data set to calculate the payment for each period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data loan_amort;&lt;BR /&gt;set loan_acct_sample;&lt;BR /&gt;rate = APR/PmtFreq;&lt;BR /&gt;nper = PmtFreq;&lt;BR /&gt;pv = LoanAmount;&lt;BR /&gt;fv = 0;&lt;BR /&gt;calc_pmt = finance('pmt',rate,nper,pv,fv);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this code, the calculated value in the payment field is way too high.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I wrote the code to create the amortization schedule table for each account:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data amort_sched;&lt;BR /&gt;set loan_amort;&lt;BR /&gt;do term = 1 to nper;&lt;BR /&gt;int_paid = pv * rate;&lt;BR /&gt;prin_paid = abs(calc_pmt) - int_paid;&lt;BR /&gt;pv = pv - prin_paid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tot_int_paid + int_paid;&lt;BR /&gt;tot_prin_paid + prin_paid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While creating the schedule is helpful, all I really need is the last record of the table which displays the total amortized interest paid and the total principal paid for each account. I was trying to suppress the previous observations so I would just have the last record and use the keep command to declare the needed variables.&amp;nbsp; I'm clearing missing something in my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to write the standard amortization formula in the following form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A = P (r(1+r)^n/(1+r)^n -1)&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A = payment amount per period&lt;/P&gt;
&lt;P&gt;P = Loan Amount (Principal)&lt;/P&gt;
&lt;P&gt;r = interest rate per period&lt;/P&gt;
&lt;P&gt;n = total number of payment periods&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this formula in my code, I get an inflated amount so I have the feeling there is a problem with how SAS is reading&lt;/P&gt;
&lt;P&gt;the order of operations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions would be greatly appreciated.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 00:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581899#M165427</guid>
      <dc:creator>greg6363</dc:creator>
      <dc:date>2019-08-17T00:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581900#M165428</link>
      <description>&lt;P&gt;The formula&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;A = P (r(1+r)^n/(1+r)^n -1)&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt; should be written as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A = P * ((r * (1+r)**n) / ((1+r)**n -1)) ;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Aug 2019 01:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581900#M165428</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-08-17T01:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581960#M165455</link>
      <description>&lt;PRE&gt;data amort_sched;
set loan_amort;

do term = 1 to nper;
        int_paid = pv * rate;
        prin_paid = abs(calc_pmt) - int_paid;
        pv = pv - prin_paid;
 
        tot_int_paid + int_paid;
        tot_prin_paid + prin_paid;
 
&lt;FONT size="5" color="#0000FF"&gt;&lt;STRONG&gt;output; *creates an output for each line;&lt;/STRONG&gt;&lt;/FONT&gt;
end;

&lt;FONT size="5" color="#FF6600"&gt;&lt;STRONG&gt;OUTPUT; *creates an output at the end only;
&lt;/STRONG&gt;&lt;/FONT&gt;
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21164"&gt;@greg6363&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Unfortunately, my SAS license does not include PROC LOAN which would solve my dilemma so I have to create a loan amortization schedule manually.&amp;nbsp; The following code attempts to utilize the loan information (APR, Payment Frequency, Loan Amount) from the sample data set to calculate the payment for each period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data loan_amort;&lt;BR /&gt;set loan_acct_sample;&lt;BR /&gt;rate = APR/PmtFreq;&lt;BR /&gt;nper = PmtFreq;&lt;BR /&gt;pv = LoanAmount;&lt;BR /&gt;fv = 0;&lt;BR /&gt;calc_pmt = finance('pmt',rate,nper,pv,fv);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this code, the calculated value in the payment field is way too high.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I wrote the code to create the amortization schedule table for each account:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data amort_sched;&lt;BR /&gt;set loan_amort;&lt;BR /&gt;do term = 1 to nper;&lt;BR /&gt;int_paid = pv * rate;&lt;BR /&gt;prin_paid = abs(calc_pmt) - int_paid;&lt;BR /&gt;pv = pv - prin_paid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tot_int_paid + int_paid;&lt;BR /&gt;tot_prin_paid + prin_paid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While creating the schedule is helpful, all I really need is the last record of the table which displays the total amortized interest paid and the total principal paid for each account. I was trying to suppress the previous observations so I would just have the last record and use the keep command to declare the needed variables.&amp;nbsp; I'm clearing missing something in my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to write the standard amortization formula in the following form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A = P (r(1+r)^n/(1+r)^n -1)&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A = payment amount per period&lt;/P&gt;
&lt;P&gt;P = Loan Amount (Principal)&lt;/P&gt;
&lt;P&gt;r = interest rate per period&lt;/P&gt;
&lt;P&gt;n = total number of payment periods&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run this formula in my code, I get an inflated amount so I have the feeling there is a problem with how SAS is reading&lt;/P&gt;
&lt;P&gt;the order of operations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions would be greatly appreciated.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 19:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581960#M165455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-17T19:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581965#M165458</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21164"&gt;@greg6363&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Though you don't have PROC LOAN licensed, Base SAS sports no fewer than 32 various financial functions, among which I'm sure you'll find what you need without having to reinvent the wheel. In your particular case, for example, you may want to take a look at the MORT (i.e. "mortgage") function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Aug 2019 19:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/581965#M165458</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-17T19:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/589728#M168714</link>
      <description>Our SAS license doesn’t even have the PPMT, IPMT, CUMPRINC or CUMIPMT functions which is why the manual processes.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Sep 2019 16:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/589728#M168714</guid>
      <dc:creator>greg6363</dc:creator>
      <dc:date>2019-09-18T16:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loan amortization problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/589742#M168719</link>
      <description>What version do you have? Also, the FINANCE function itself does some of those.</description>
      <pubDate>Wed, 18 Sep 2019 17:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loan-amortization-problem/m-p/589742#M168719</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-18T17:04:15Z</dc:date>
    </item>
  </channel>
</rss>

