BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abud
Calcite | Level 5

Hi all,

I'm trying to compare two variables macro (price_trd vs max_price) however as the example below that's not happening....

Please someone could give me a little help ?

TK'S IN ADVANCED!

########## CODE BELOW #########

options mlogic mprint;

%let price_trd = 93.68;

%put &price_trd.;

%let max_price = 100.94;

%put &max_price.;

%macro test;

  %if  &price_trd. < &max_price %then %do;

  %put Pass HERE;

  %end;

%mend;

%test;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Need to use %SYSEVALF() to do floating point calculations, otherwise macro will attempt to use %EVAL() which only does integer math.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Need to use %SYSEVALF() to do floating point calculations, otherwise macro will attempt to use %EVAL() which only does integer math.

Reeza
Super User

Wrap the comparison in %sysevalf

E.G.

  %if  %sysevalf(&price_trd. LT &max_price) %then %do;

As always in the fine print (floating point arithmetic vs integer for %eval).

SAS(R) 9.2 Macro Language: Reference

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
  • 2 replies
  • 9729 views
  • 6 likes
  • 3 in conversation