Hi, guys:
I try to take the division operation on macro variables, but it does not work. Can you give me some idea how to do it.
As a simple example, I have a variable, xx=5 and I want to generate yy that yy=1/xx=.2. Both variables are macro variables.
My code is the following
%let xx=5;
%let yy=1/%eval(&xx.);
%put &yy.;
The outcome is yy=0.
It seems to be the case that the division operation causing the trouble. I even tried %let zz=%eval(1/5). The outcome is still 0.
Thanks for your input.
%let xx=5;
%let yy=%SYSEVALF(1/&xx);
%put yy=&yy;
%SYSEVALF will do floating, while %eval will only do integer.
Haikuo
%let xx=5;
%let yy=%SYSEVALF(1/&xx);
%put yy=&yy;
%SYSEVALF will do floating, while %eval will only do integer.
Haikuo
Hi, Hai.Kuo:
Thanks for the input. It works.
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.