DATA Step, Macro, Functions and more

%eval return an boolean value, how?

Frequent Contributor
Posts: 133

%eval return an boolean value, how?

Can anyone give an example of %eval that returns a boolean value, true/false?

In sas help, it says "If at least one operand cannot be interpreted as numeric, the expression is treated as logical."

But it doesn't give an example,  I tried following:


it returned an error

I can't think of one example.

Super User
Super User
Posts: 8,130

%eval return an boolean value, how?

Use %SYSEVALF if you want to enforce the format of the returned value.

%sysevalf(4+5,boolean) will return 1 instead of 9.

Super User
Posts: 6,789

%eval return an boolean value, how?

You can also simulate the result, using %EVAL.  This expression also returns a 1:

%eval ( (4+5) ne 0) 

However, %SYSEVALF will also return 0 for calculated missing values.  %EVAL returns an error.

Also note that %EVAL is still limited to integer arithmetic.  These expressions return different results:

%sysevalf(4/5, boolean)

%eval( (4/5) ne 0)

Hope this helps, rather than confuses the issue!

Regular Contributor
Posts: 241

Re: %eval return an boolean value, how?

Here is an example. hth

%put %eval( 1.0 eq 1);
%*-- returns 0 for false -- *;

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation