<?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 Proc loan + estimatedcase - add values from a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832875#M329243</link>
    <description>&lt;P&gt;Say I have an adjustable rate loan of 1000 granted in 2015 with interest rate being adjusted annually. I want to obtain repayment schedule for this loan given known past rates and find the outstanding value of the loan at the end of 2020:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rates;
input year rate;
datalines;
2015 1.5
2016 2
2017 3
2019 2.5
2019 4
2020 5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The proc loan, together with the ESTIMATEDCASE option seems to be doing what I want, but can I read the values to be placed in the&amp;nbsp;ESTIMATEDCASE from a dataset instead of giving them manually?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc loan start=2010:12;
arm amount=1000 rate=1.5 life=180 ESTIMATEDCASE=(12=2, 24=3, 36=2.5, 48=4, 52=5)
label='BANK3, Adjustable Rate';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 14:16:56 GMT</pubDate>
    <dc:creator>chris2377</dc:creator>
    <dc:date>2022-09-12T14:16:56Z</dc:date>
    <item>
      <title>Proc loan + estimatedcase - add values from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832875#M329243</link>
      <description>&lt;P&gt;Say I have an adjustable rate loan of 1000 granted in 2015 with interest rate being adjusted annually. I want to obtain repayment schedule for this loan given known past rates and find the outstanding value of the loan at the end of 2020:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data rates;
input year rate;
datalines;
2015 1.5
2016 2
2017 3
2019 2.5
2019 4
2020 5
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The proc loan, together with the ESTIMATEDCASE option seems to be doing what I want, but can I read the values to be placed in the&amp;nbsp;ESTIMATEDCASE from a dataset instead of giving them manually?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc loan start=2010:12;
arm amount=1000 rate=1.5 life=180 ESTIMATEDCASE=(12=2, 24=3, 36=2.5, 48=4, 52=5)
label='BANK3, Adjustable Rate';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 14:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832875#M329243</guid>
      <dc:creator>chris2377</dc:creator>
      <dc:date>2022-09-12T14:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc loan + estimatedcase - add values from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832906#M329247</link>
      <description>&lt;P&gt;The documentation indicates that&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/etsug/etsug_loan_syntax04.htm" target="_self"&gt;PROC LOAN&lt;/A&gt;&amp;nbsp;does not accept a dataset, so we can work around that using macros&lt;BR /&gt;&lt;BR /&gt;Here's an example:&lt;BR /&gt;&lt;BR /&gt;&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
2019 2.5
2019 4
2020 5
;
run;

/* Put the macro variable to the log (for debugging) */
%put &amp;amp;=EC ;

proc loan start=2015:6;
	/* use the macro variable EC in the ESTIMATEDCASE option */
	arm amount=1000 rate=0 life=180 ESTIMATEDCASE=(&amp;amp;EC)
	label='BANK3, Adjustable Rate';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Sep 2022 14:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-loan-estimatedcase-add-values-from-a-dataset/m-p/832906#M329247</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2022-09-12T14:36:38Z</dc:date>
    </item>
  </channel>
</rss>

