turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- why result is 1 for %put %eval( 1000.1 LE 1000.1);...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-11-2012 06:10 PM

%put %eval( 1000.1 LE 1000.1);

how does sas treat 1000.1 in this case?

Why it becomes 1 when running sas.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ZRick

04-11-2012 07:19 PM

%EVAL generally only understands integers. The comparison value of the LE statement is what you have asked %EVAL to report. SAS will return 1 for true and 0 for false as it doesn't have an actuall Boolean data type. So 1000.1 is less than or equal to 1000.1 and the result is 1.

If you change to LT for strictly less than you would get a result of 0 since the comparison would be false.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ZRick

04-12-2012 09:06 AM

Also note ... because of the decimal point, %EVAL is forced to make a character comparison. (As was noted, %EVAL can perform arithmetic with integers only.) This expression would also return 1 because of the decimal point:

%eval( 9. > 80)

Since %sysevalf can perform non-integer arithmetic, this expression returns 0:

%sysevalf( 9. > 80)