<?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: Passing variable arguments to Finance(XIRR) function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92815#M19560</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The range on "N" is variable. It can be 1 as it can be 5000. N is calculated through two variables (date1 and date2) in my input data like N=date2-date1, which is the number of times that i have to calculate IRR for that row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each row the calculation goes like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1- Calculate "N" for that row&lt;/P&gt;&lt;P&gt;2- Calculate IRR for the row "N" times like:&lt;/P&gt;&lt;P&gt;N=1&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,per1,per2);&lt;/P&gt;&lt;P&gt;N=2&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,amt3,per1,per2,per3);&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;N=N&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,...,amtN+1,per1,per2,...,perN+1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i understood your suggestion, what i have at the moment is like what you suggested.&lt;/P&gt;&lt;P&gt;I'm doing a first iteration of the input data to calculate max(N) so that in a second iteration i generate the select clause with macro coding. The problem here is the complexity of the iteration. I have: N rows * date2-date1 cycles * MAX(N) if tryes.&lt;/P&gt;&lt;P&gt;Has you can imagine, even with a small subset of data, it takes a while to compute this. The first two components of the formula are impossible to remove but the MAX(N) if tryes could be removed if there was a way to pass to the function a list of values, which i feel there isn't.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jun 2012 18:50:22 GMT</pubDate>
    <dc:creator>PAzevedo</dc:creator>
    <dc:date>2012-06-26T18:50:22Z</dc:date>
    <item>
      <title>Passing list of arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92812#M19557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got a project where i need to calculate&amp;nbsp; the Internal Rate of Return for non periodic payments.&lt;/P&gt;&lt;P&gt;I'm using the XIRR Finance function to do it but i can't seem to find how to use it with variable input, or even if it's possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got a dataset with lots of rows and i need to calculate the XIRR for each row.&lt;/P&gt;&lt;P&gt;The problem is that every row as a different number of periods and the function doesn't seem to accept arguments like amt(1)-amt(n), neither i can use syntax like amt1-amtn as "n" is different in each row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider the following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: navy; font-family: 'Courier New';"&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;input&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; amt1-amt5 per1-per5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New';"&gt;-100 101 102 103 . 1 2 3 4 . &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: #ffffc0; color: black; font-family: 'Courier New';"&gt;-100 101 102 103 105 1 2 3 4 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the first row i need to call the function for the first 4 amounts and periods:&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,amt3,amt4,per1,per2,per3,per4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the second row i need to call the function for the first 5 amounts and periods:&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,amt3,amt4,amt5,per1,per2,per3,per4,per5);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now imagine this with a lot of input rows, each one with different amounts and periods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment i'm using a giant if trying the value for "n", generated by macro code based on the max periods i have in the input data which, as you can imagine, is heavy dutty! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 16:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92812#M19557</guid>
      <dc:creator>PAzevedo</dc:creator>
      <dc:date>2012-06-26T16:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92813#M19558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the range of your N?&lt;/P&gt;&lt;P&gt;It may be possible to test for the number of nonmissing arguments, for your example : test= 5 - nmiss(amt1-amt5)&lt;/P&gt;&lt;P&gt;and then use a select (test) to branch to the appropriate calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select(test);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (2) irr=finance(amt1,amt2,per1,per2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (3) irr=finance(amt1,amt2,amt3,per1,per2,per3);&lt;/P&gt;&lt;P&gt;/*to your max n*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;admittedly if n gets large this is a tad clumsy but if you write the longest one first then copy paste in the editor and remove items doesn't take that long.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 18:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92813#M19558</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-06-26T18:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92814#M19559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First of all, I know close to nothing about this finance function, so I am not surprised that there are better solutions. It seems to me that:&lt;/P&gt;&lt;P&gt;1. Finance function does not take missing value as mean, max or other math functions, so when there is a missing value, the result will be missing.&lt;/P&gt;&lt;P&gt;2. Finance function does not take variable list very well, so you need to spell out all of the variable names explicitly.&lt;/P&gt;&lt;P&gt;3. In 'xirr' scenario, missing value can be replaced by zero????( not sure of this part, just a wild guess from comparing results).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So given above, you can try the following, first you need to replace all of the missings with zero, then just use one universal function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;input amt1-amt5 per1-per5; &lt;/P&gt;&lt;P&gt;array ir _numeric_;&lt;/P&gt;&lt;P&gt;do over ir;&lt;/P&gt;&lt;P&gt;ir+0;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,amt3,amt4,amt5,per1,per2,per3,per4,per5);&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;-100 101 102 103 . 1 2 3 4 .&lt;/P&gt;&lt;P&gt;-100 101 102 103 105 1 2 3 4 5&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 18:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92814#M19559</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-06-26T18:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92815#M19560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The range on "N" is variable. It can be 1 as it can be 5000. N is calculated through two variables (date1 and date2) in my input data like N=date2-date1, which is the number of times that i have to calculate IRR for that row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each row the calculation goes like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1- Calculate "N" for that row&lt;/P&gt;&lt;P&gt;2- Calculate IRR for the row "N" times like:&lt;/P&gt;&lt;P&gt;N=1&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,per1,per2);&lt;/P&gt;&lt;P&gt;N=2&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,amt3,per1,per2,per3);&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;N=N&lt;/P&gt;&lt;P&gt;IRR=FINANCE('XIRR',amt1,amt2,...,amtN+1,per1,per2,...,perN+1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i understood your suggestion, what i have at the moment is like what you suggested.&lt;/P&gt;&lt;P&gt;I'm doing a first iteration of the input data to calculate max(N) so that in a second iteration i generate the select clause with macro coding. The problem here is the complexity of the iteration. I have: N rows * date2-date1 cycles * MAX(N) if tryes.&lt;/P&gt;&lt;P&gt;Has you can imagine, even with a small subset of data, it takes a while to compute this. The first two components of the formula are impossible to remove but the MAX(N) if tryes could be removed if there was a way to pass to the function a list of values, which i feel there isn't.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 18:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92815#M19560</guid>
      <dc:creator>PAzevedo</dc:creator>
      <dc:date>2012-06-26T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92816#M19561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure there is another way of implementing calculation that needs XIRR then implementing the algorithm behind it.&lt;/P&gt;&lt;P&gt;Since the original algorithm has a summatory i believe it wont much better or even better than using the finance function.&lt;/P&gt;&lt;P&gt;What you stated about the function is all true and as given me a real pain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i'm preatty sure your sugestion takes some complexity out of the algorithm i currently have.&lt;/P&gt;&lt;P&gt;To give an idea of what i'm currently facing here is a sample of the code (The code is simplified, there are some hash and key searches in the middle of this):&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;DO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; I=DATE1+&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;TO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; DATE2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; PERIOD+&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; PER(PERIOD)=I;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; CASHFLOWS(PERIOD)=TEQUIV/&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;100&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;/&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;365&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;*&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;*-CASHFLOWS(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; AMT(PERIOD)=ABS(AMT(PERIOD-&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;))+CASHFLOWS(PERIOD);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;SELECT&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; (PERIOD);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%DO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; I=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;2&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%TO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; &amp;amp;MAXP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;WHEN&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; (&amp;amp;I) TIR=FINANCE(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: purple; font-family: 'Courier New';"&gt;'XIRR'&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%DO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; J=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%TO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; &amp;amp;I;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AMT(&amp;amp;J),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%END&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%DO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; J=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="background: white; color: teal; font-family: 'Courier New';"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN lang="EN-US" style="background: white; color: blue; font-family: 'Courier New';"&gt;%TO&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt; &amp;amp;I;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PER(&amp;amp;J),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;%END&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;.05&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;)*&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;100&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;%END&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New';"&gt;OTHERWISE&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 11pt; background: white; color: blue; font-family: 'Courier New';"&gt;END&lt;/SPAN&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; background: white; color: blue; font-family: 'Courier New';"&gt;END&lt;/SPAN&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;Each of the three arrays (cashflows, amt, per) are set to missing at the beggining of each iteration (call missing).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;Setting them to zero at the beggining of each iteration, instead of missing, and calling the function with &amp;amp;maxp arguments instead of using the select clause might make this go faster.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;I'll just have to evaluate if having zeros gives me the same result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt; background: white; color: black; font-family: 'Courier New';"&gt;It was a nice tip, thk you.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 19:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92816#M19561</guid>
      <dc:creator>PAzevedo</dc:creator>
      <dc:date>2012-06-26T19:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92817#M19562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about expanding the original suggestion of using zeros?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use just one formula, for the maximum time period.&amp;nbsp; Run through a DO loop, each time setting one more value to 0 (starting at the end of the time periods and working back toward the beginning).&amp;nbsp; You'll be setting actual non-zero values to 0 along the way.&amp;nbsp; The question is, would the function generate the proper answer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 20:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92817#M19562</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-06-26T20:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92818#M19563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this using the already mentioned conversion of missing to zersos.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; amt1-amt5 per1-per5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: #ffffc0; color: black; font-family: 'Courier New';"&gt;-100 101 102 103 . 1 2 3 4 . &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: #ffffc0; color: black; font-family: 'Courier New';"&gt;-100 101 102 103 105 1 2 3 4 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;stdize&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;reponly&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;method&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;sum&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;missing&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=a2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;var&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;_all_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; a2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; a2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; IRR=FINANCE(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: purple; font-family: 'Courier New';"&gt;'XIRR'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;,of amt: per:);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 21:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92818#M19563</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-06-26T21:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Passing list of arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92819#M19564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OR You can use lots of&amp;nbsp; Macro variable . But I am sure it isn't suited for large table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data a;
input amt1-amt5 per1-per5;
cards;
-100 101 102 103 . 1 2 3 4 .
-100 101 102 103 105 1 2 3 4 5
;
run;
options missing=' ';
proc sql noprint;
 select count(*) into : n from a;
 select catx(",","IRR=FINANCE('XIRR'",amt1,amt2,amt3,amt4,amt5,per1,per2,per3,per4,per5)||");output;"
&amp;nbsp;&amp;nbsp; into : list1 - : list%left(&amp;amp;n) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; from a;
quit;

%macro a;
data want;
%do i=1 %to &amp;amp;n ;
 &amp;amp;&amp;amp;list&amp;amp;i
%end;
run;
%mend a;
%a 
 


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 03:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92819#M19564</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-06-27T03:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Passing variable arguments to Finance(XIRR) function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92820#M19565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Last idea for me ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I imagine that the formula for an internal rate of return is not that complicated.&amp;nbsp; You already have arrays set up, with a DO loop, to populate CASHFLOWS and AMT for each period.&amp;nbsp; Why not just set up a few more arrays (and possibly a variable or two holding cumulative numbers across all prior periods), and let your current DO loop calculate the internal rate of return without using a function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 13:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-list-of-arguments-to-Finance-XIRR-function/m-p/92820#M19565</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-06-27T13:39:01Z</dc:date>
    </item>
  </channel>
</rss>

