Reputation: 111
I have two numeric variables in SAS
:
%let var1=10;
%let var2=8;
I have to do the division between the two, but if I do:
%let var3=%eval(&var2/&var1);
%put &var3;
the result is 0
. Because var2
is a subset of var1
and by default the system rounds the number to 0
. In fact if I do &var1/&var2
the result is 1
.
Given that I have to use this value for a percent I have the need that it is maintained with the decimal.
How can I overcome this?
Upvotes: 0
Views: 724
Reputation: 51611
You need to use %SYSEVALF()
if you want something other than integer arithmetic.
Macro code is for generating text. If you really need to do calculations you should do it in a data step.
Upvotes: 3