BookmarkSubscribeRSS Feed
ZRick
Obsidian | Level 7

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:

%eval('0'+1);

it returned an error

I can't think of one example.

3 REPLIES 3
Tom
Super User Tom
Super User

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

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

Astounding
PROC Star

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!

chang_y_chung_hotmail_com
Obsidian | Level 7

Here is an example. hth

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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2776 views
  • 1 like
  • 4 in conversation