Mike, Looks like what you want to do is something like this: Data out;
set have;
array dates (*) date1-date&Num_leases;
array values(*) value1-value&Num_leases;
/* code to populate arrays here */
IRR=finance('XIRR',<dynamic portion of values>,<dynamic portion of dates>);
run;
Unfortunately, there is no way you can refer to a dynamic number of values in a function call like that. One way out of that could be to code a select statement: select (n(of values(*)); /* select on non-missing values */
when(0); /* not sure what to do here... */
when(1) IRR=finance('XIRR',value1,date1);
when(2) IRR=finance('XIRR',of value1-value2,of date1-date2);
when(3) IRR=finance('XIRR',of value1-value3,of date1-date3); Which can, of course, be coded as a macro. But I think the easy way out is to replace the missing values with zeros: do i=1 to dim(dates);
if missing(values(i)) then do; values(i)=0; dates(i)=0; /* does not matter what the date is, but it cannot be missing */ end; end; The FINANCE function does not accept missing values, but any number of zero values does not change the result, so you can then just do IRR=finance('XIRR',of values(*),of dates(*));
... View more