<?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: Invalid argument to function FINANCE 'Rate' with negative interest rate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890601#M351920</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446395"&gt;@IgorR&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, if you don't want to rely on the FINANCE function (let alone on Excel), it's maybe best to use your own formulas. Here's what this might look like in the special case &lt;FONT face="courier new,courier"&gt;Pv=0&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Type=1&lt;/FONT&gt;, which you use in your example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.finance;
function f(nper, r);
  return((r**(nper+1)-r)/(r-1));
endsub;

function rate(nper, payment, fv);
  p=round(solve('f',{.},-fv/payment,nper,.)-1, 1e-10);
  return(p);
endsub;
run;

options cmplib=work.funcs;

data test;
input nper payment fv;
p=rate(nper, payment, fv);
cards;
1 -94   76.96
2 -10   10
3 -50  150
4 -25  110
6 -30 9999  
8 -12   97
8  12  -97
;

proc print data=test;
format payment 8.2 p percentn10.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    nper     payment          fv             p

 1       1       -94.00       76.96      -18.13%
 2       2       -10.00       10.00      -38.20%
 3       3       -50.00      150.00        0.00%
 4       4       -25.00      110.00        3.85%
 5       6       -30.00     9999.00      141.02%
 6       8       -12.00       97.00        0.23%
 7       8        12.00      -97.00        0.23%&lt;/PRE&gt;
&lt;P&gt;As far as I see, the results above match those obtained with Excel (up to rounding errors).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I leave it to you to generalize this approach to cases with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Pv ne 0&lt;/FONT&gt;&amp;nbsp;or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Type=0&lt;/FONT&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2023 17:51:06 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2023-08-23T17:51:06Z</dc:date>
    <item>
      <title>Invalid argument to function FINANCE 'Rate' with negative interest rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890547#M351904</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I am trying to convert Excel function "RATE" to SAS code.&lt;BR /&gt;But it turns out that the function FINANCE("RATE") cannot accept a negative value of interest.&lt;/P&gt;&lt;P&gt;I have a next parameters:&lt;/P&gt;&lt;P&gt;Nper = 1,&lt;/P&gt;&lt;P&gt;Payment = -94,&lt;/P&gt;&lt;P&gt;Pv = 0,&lt;/P&gt;&lt;P&gt;Fv = 76.96,&lt;/P&gt;&lt;P&gt;Type = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In excel these parameters returns result -18.13% (minus 18.13%).&lt;/P&gt;&lt;P&gt;In SAS I get missing value.&lt;/P&gt;&lt;P&gt;In SAS I'm trying to calculate this by this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Result = FINANCE('RATE', nper, payment, pv, fv, type);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please, help me to find a way to make calculation that can handle both negative and positive parameters and zeroes as well.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 12:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890547#M351904</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-23T12:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function FINANCE 'Rate' with negative interest rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890550#M351906</link>
      <description>&lt;P&gt;You could make the payment 94, and then you should get a rate, and then you can multiply the rate by -1.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 12:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890550#M351906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-23T12:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function FINANCE 'Rate' with negative interest rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890601#M351920</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446395"&gt;@IgorR&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, if you don't want to rely on the FINANCE function (let alone on Excel), it's maybe best to use your own formulas. Here's what this might look like in the special case &lt;FONT face="courier new,courier"&gt;Pv=0&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;Type=1&lt;/FONT&gt;, which you use in your example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.finance;
function f(nper, r);
  return((r**(nper+1)-r)/(r-1));
endsub;

function rate(nper, payment, fv);
  p=round(solve('f',{.},-fv/payment,nper,.)-1, 1e-10);
  return(p);
endsub;
run;

options cmplib=work.funcs;

data test;
input nper payment fv;
p=rate(nper, payment, fv);
cards;
1 -94   76.96
2 -10   10
3 -50  150
4 -25  110
6 -30 9999  
8 -12   97
8  12  -97
;

proc print data=test;
format payment 8.2 p percentn10.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    nper     payment          fv             p

 1       1       -94.00       76.96      -18.13%
 2       2       -10.00       10.00      -38.20%
 3       3       -50.00      150.00        0.00%
 4       4       -25.00      110.00        3.85%
 5       6       -30.00     9999.00      141.02%
 6       8       -12.00       97.00        0.23%
 7       8        12.00      -97.00        0.23%&lt;/PRE&gt;
&lt;P&gt;As far as I see, the results above match those obtained with Excel (up to rounding errors).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I leave it to you to generalize this approach to cases with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Pv ne 0&lt;/FONT&gt;&amp;nbsp;or&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Type=0&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 17:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890601#M351920</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-08-23T17:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function FINANCE 'Rate' with negative interest rate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890699#M351942</link>
      <description>&lt;P&gt;@&amp;nbsp;FreelanceReinh,&lt;/P&gt;&lt;P&gt;I am incredibly amazed by your brilliant solution.&lt;/P&gt;&lt;P&gt;I see how much I still have to learn.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 07:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-FINANCE-Rate-with-negative-interest/m-p/890699#M351942</guid>
      <dc:creator>IgorR</dc:creator>
      <dc:date>2023-08-24T07:10:38Z</dc:date>
    </item>
  </channel>
</rss>

