I have a macro in SAS that is not working correctly. I have a %goto statement that is triggered if a macro variable's value is larger than some fixed number. The macro variable is created by the following sample code;
proc sql noprint;
select num into :num
from table;
quit;
When opening up the table, the num variable has the number in standard notation (e.g. 645,435,243). However, the macro variable &num. picks it up as 6.4544E8. This causes an issue then when SAS attempts to compare this value to a number such as 1,000,000.
I was able to recreate this issue with the simple macro below, the only difference is in the way the macro variable is assigned the value. In the code below, I assign j 1E8 directly rather than through a proc sql statement.
My question is this: why is SAS unable to evaluate 1E8 > 5 correctly?
%macro test();
%let i = 1;
%let j = 1E8;
data test0;
x = &i.;
output;
run;
%let i = 2;
%do %until (&i. = 11);
%put &i.;
%if &i. >= 7 %then %do;
%if &j. > 5 %then %do;
%goto done;
%end;
%end;
data test&i.;
x = &i.;
output;
run;
proc append base=test0 data=test&i.;
run;
proc datasets library=work nolist;
delete test&i.;
run;
%let i = %eval(&i + 1);
%end;
%done: %mend;
%test();