<?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: proc loan output vs. finance function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832975#M329279</link>
    <description>&lt;P&gt;Why not just look at the FV's after one and/or two payments?&amp;nbsp; If they are different, it may be a lot easier to determine what the underlying algorithm is in each.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 18:51:38 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-09-12T18:51:38Z</dc:date>
    <item>
      <title>proc loan output vs. finance function SOLVED - see the end of the initial post</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832973#M329277</link>
      <description>&lt;P&gt;I MANAGED TO SOLVE THE PROBLEM - SEE THE CODE AT THE END OF THE POST&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Below is the code to prepare loan repayment schedule using proc loan with estimatedcase option, provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226241"&gt;@AMSAS&lt;/a&gt;&amp;nbsp; in this topic: &lt;LI-MESSAGE title="Proc loan + estimatedcase - add values from a dataset" uid="832875" url="https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832875#U832875" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the procedure output, I can read the outstanding balance of the loan after 12 payments (in December 2015 in this example) which is: &lt;STRONG&gt;933.28&lt;/STRONG&gt;. But when I calculate this "manually", using finance function to obtain FV of the loan after 12 payments, I get a different value (&lt;STRONG&gt;940.1&lt;/STRONG&gt;). Where is the difference comming from? What is the correct oustanding value of the loan? I trust more the result from the finance function, as I can get similar value using Excel.&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 rates;
	/* define temporary varible and retain */
	/* Note if your periods and rates, exceed the length you will have problems */
	length 
		tempEC $200 ;
	retain 
		tempEC ""
		start  2015 ; /* Set loan start year */
	/* Read your data */
	input year rate;
	/* Convert the years into periods (month) from the start date */
	months=(year-start)*12 ;
	/* Handle case where 1st rate is at the start of the loan */
	if months=0 then 
		months=1 ;
	/* Add seperator if more than 1 period/rate */
	if _n_ ne 1 then do ;
		tempEC=cats(tempEC,", ") ;
	end ;
	/* Build code syntax */
	tempEC=cats(tempEC,putn(months,"8."),"=",putn(rate,"8.2")) ;
	/* Capture if the length of tempEC hits the maximum (200) and retutn an ERROR */
	if length(tempEC)=200 then 
		put "ERROR: tempEC exceeeded length : " ;
		put "       " tempEC ;
	/* Create macro variable for use in PROC LOAN */
	call symput("EC",tempEC) ;
	/* Put the syntax to the log (for debugging) */
	put tempEC= ;
datalines;
2015 1.5
2016 2
2017 3
2018 2.5
2019 4
2020 5
;
run;

/* Put the macro variable to the log (for debugging) */
%put &amp;amp;=EC ;

proc loan start=2014:12;
	/* use the macro variable EC in the ESTIMATEDCASE option */
	arm amount=1000 rate=0 life=180 ESTIMATEDCASE=(&amp;amp;EC) schedule = 1
	label='BANK3, Adjustable Rate';
run;

/* Cross-check using finance function to get FV of the loan*/
data finance;
	monthly_pmt = pmt(1.5/100/12, 180, -1000);
	outst_loan = -FINANCE('fv', 1.5/100/12, 12, monthly_pmt, 1000, 0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MY SOLUTION:&lt;/P&gt;
&lt;P&gt;The correct code for the proc loan is as below: in the red part there should be "rate=1.5", not "rate=0" to correctly specify the rate for the first period. Now, the figures from different functions, procedures and Excel are the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc loan start=2014:12;
	/* use the macro variable EC in the ESTIMATEDCASE option */
	arm amount=1000 &lt;FONT color="#FF0000"&gt;rate=1.5&lt;/FONT&gt; life=180 ESTIMATEDCASE=(&amp;amp;rates) schedule = 1
	label='BANK3, Adjustable Rate';
run;&lt;/PRE&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;</description>
      <pubDate>Mon, 12 Sep 2022 19:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832973#M329277</guid>
      <dc:creator>chris2377</dc:creator>
      <dc:date>2022-09-12T19:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc loan output vs. finance function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832975#M329279</link>
      <description>&lt;P&gt;Why not just look at the FV's after one and/or two payments?&amp;nbsp; If they are different, it may be a lot easier to determine what the underlying algorithm is in each.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 18:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832975#M329279</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-09-12T18:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc loan output vs. finance function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832984#M329287</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; I've managed to find the reason. But thanks for the suggestion!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 19:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-loan-output-vs-finance-function-SOLVED-see-the-end-of-the/m-p/832984#M329287</guid>
      <dc:creator>chris2377</dc:creator>
      <dc:date>2022-09-12T19:28:45Z</dc:date>
    </item>
  </channel>
</rss>

