Hello!
Is there any simple way to show values of all function parameters?
Ex. I have the following program:
data mydata;
...
x = finance('xirr', a, b, c, d, e, f, g, h, i, j, 0.1);
..
run;
Of cause, I can use put instructions just before function calling
data mydata;
...
put a=;
put b=;
put c=;
put d=;
put e=;
put f=;
put g=;
put h=;
put i=;
put j=;
x = finance('xirr', a, b, c, d, e, f, g, h, i, j, 0.1);
...
run;
But can I add some single instruction (or option) to automatically show all values of function parameters in log when it is executed? Ex. option mlogic allows us printing all values of macro parameters. May be there is some analogue of this option for SAS functions.
Thanks!
Use a variable list.
Your function call
x = finance('xirr', a, b, c, d, e, f, g, h, i, j, 0.1);
could also be written as
x = finance('xirr',of a b c d e f g h i j 0.1);
So put that list of variables/values into a macro variable and use it in both the assignment statement and a PUT statement.
%let varlist= a b c d e f g h i j;
...
x = finance('xirr',of &varlist 0.1);
put (x &varlist) (=);
Hi Dimitri,
I wish there was. But, caveat emptor, there isn't. You could shorten your example of putting all variables by using
put _all_;
But that's as good as it gets.
Regards,
-- Jan.
If you like you can code:
array arg {*} a b c d e f g h i;
do _m_ = 1 to dim(arg);
put strip(vname(arg(_M))) ' = ' arg(_M_);
end;
drop _m_;
@DmitryErshov wrote:
data mydata; ... put a=; put b=; put c=; put d=; put e=; put f=; put g=; put h=; put i=; put j=; x = finance('xirr', a, b, c, d, e, f, g, h, i, j, 0.1); ... run;
Hello @DmitryErshov,
put (a--j)(=);
would not only be shorter code, but normally also take up less space in the log. However, it requires that a is the first and j the last variable of the list in the order of their logical position in the data set (see PROC CONTENTS output with VARNUM option).
In many practical applications SAS handles so many observations that such log output would become unwieldy. A common situation where it is very useful to display variable values and to see how they change during a DATA step is the debugging process. The data step debugger does have this functionality. Please see this post for a brief instruction: https://communities.sas.com/t5/SAS-Programming/use-of-index/m-p/264460#M51865.
Thank you very much for your replies!
Regards,
Dmitry
Use a variable list.
Your function call
x = finance('xirr', a, b, c, d, e, f, g, h, i, j, 0.1);
could also be written as
x = finance('xirr',of a b c d e f g h i j 0.1);
So put that list of variables/values into a macro variable and use it in both the assignment statement and a PUT statement.
%let varlist= a b c d e f g h i j;
...
x = finance('xirr',of &varlist 0.1);
put (x &varlist) (=);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.