I'm trying to use the FINANCE('XIRR'....) function within the IML (must perform many interactions, so IML is the best place), however, I cannot get it to work. I understand can be done in a Data Step, by transposing the data etc, however, we must run so many loops that the data step option will take to long, Here are two sample codes, trying to load the values from a table on this function, none of these work, any suggestion?
Yes, this can be tricky. I need to write a blog post about this (http://blogs.sas.com/iml), since several people have asked a similar question.
The issue, for those not familiar with calling Base SAS functions, is that some Base SAS functions string out their arguments in a list, whereas in SAS/IML it is convenient to be able to pass a vector of values.
The trick is to convert the vector of values into a comma-delimted string, and then stick the string into a macro variable by using the SYMPUT function. (This technique appears in my book Statistical Programming with SAS/IML Software: http://support.sas.com/publishing/authors/wicklin.html)
The following statements define a SAS/IML module called GetArgList that taks a vector of values and creates a comma-delimited string from it. You can then stick that string into the macro &myArgs, and use it in the FINANCE function:
/* convert numeric elements to a single string */
y = strip(putn(rowvec(v),"BEST12.")) + ",";
/* get rid of last comma */
y[ncol(y)] = strip(putn(v[ncol(y)],"BEST12."));
return( rowcat(y) ); /* scalar string */
read all var _ALL_ into values;
call symput("myArgs", GetArgList(values));
r = finance('xirr', &myArgs, 0.1);
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.