DATA Step, Macro, Functions and more

Scientific notation on macro

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 144
Accepted Solution

Scientific notation on macro

Hi,

 

Yesterday, I was programming on macro and I realized that in a macro evaluation 10 is not equal than 1e1, but in a data step it says that they are equal.

 

%put %eval(10=1e1);
0

data test;
if 10=1e1 then put "1";
run;

1

 

Why happen this?


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
Respected Advisor
Posts: 3,886

Re: Scientific notation on macro

You need "%sysevalf()". Run the following

 

data _null_;
var= 10=1e1;
put var=;
run;

%put eval: %eval(10=1e1);
%put sysevalf: %sysevalf(10=1e1);

 

 

View solution in original post


All Replies
Solution
‎09-25-2015 06:23 AM
Respected Advisor
Posts: 3,886

Re: Scientific notation on macro

You need "%sysevalf()". Run the following

 

data _null_;
var= 10=1e1;
put var=;
run;

%put eval: %eval(10=1e1);
%put sysevalf: %sysevalf(10=1e1);

 

 

Super User
Posts: 6,926

Re: Scientific notation on macro

The macro processor is a pure text engine, so you need to see all comparisons as character comparisons, unless you override that behaviour, as Patrick already pointed out.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 208 views
  • 1 like
  • 3 in conversation