Thanks @FreelanceReinh
So the good news is it is a bug and it can be confirmed...
Bad news it is there not fixed since M5! ...
Here (https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1alyfc9f4qrten10sd5qz5e1w5q.htm) in the table, if you count with mnemonics there is more than 26 operators, maybe IN is 26th? BTW. What happens if you replace "IN" with "#", like:
%if %sysevalf(1 # 1) %then %put OK;
?
"YJEVAL" - "something, something EVAL", maybe %YJEVAL() is like "Yet another Junky EVAL"? 😄 😄
Could you also do test for "1 in (1 2 3)" ? Just to have a full picture for SAS Support team.
Bart
@yabwon wrote:
Here (https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1alyfc9f4qrten10sd5qz5e1w5q.htm) in the table, if you count with mnemonics there is more than 26 operators, maybe IN is 26th? BTW. What happens if you replace "IN" with "#", like:
%if %sysevalf(1 # 1) %then %put OK;?
Almost the same as with "IN", but the number changed from 26 to 13:
... YJEVAL: Invalid arithmetic operator 13 encountered. ...
@yabwon wrote:Could you also do test for "1 in (1 2 3)" ? Just to have a full picture for SAS Support team.
Same messages as in your initial post.
SAS has just told me (twice!) that there will be an %IN operator (or at least a "reserved keyword" of this name) in a future SAS release.
6 %macro test / minoperator; 7 %if %sysevalf(1 %IN 1) %then %put OK; 8 %mend; 9 10 %test NOTE: %IN will become a reserved keyword of the SAS Macro Language in a future release of the SAS System. Changing the name of this macro will avoid future conflicts. WARNING: Apparent invocation of macro IN not resolved. NOTE: %IN will become a reserved keyword of the SAS Macro Language in a future release of the SAS System. Changing the name of this macro will avoid future conflicts. WARNING: Apparent invocation of macro IN not resolved. ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 1 %IN 1 ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition. ERROR: The macro TEST will stop executing.
Maybe that will be more robust.
Thanks!
From 26 to 13, so maybe my guessing was right 🙂
9.4M8 has the same note about %IN, so still not reserved 😄
1 %in
-
180
NOTE: %IN will become a reserved keyword of the SAS Macro Language in a future release of the SAS System. Changing the name of this macro will avoid future conflicts.
WARNING: Apparent invocation of macro IN not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
Bart
@FreelanceReinh wrote:
NOTE: %IN will become a reserved keyword of the SAS Macro Language in a future release of the SAS System. Changing the name of this macro will avoid future conflicts.
That's interesting! I remember (I think) Ian Whitlock in a macro class opining about whether or not it would have been a better design decision for the macro language to use % signs for all operators, %AND, %OR, etc.
@yabwon wrote:
"YJEVAL" - "something, something EVAL", maybe %YJEVAL() is like "Yet another Junky EVAL"? 😄 😄
I googled for YJEVAL and found this 20 year old SAS-L thread where a # sign started throwing the error in 9.1 when it was introduced as a mnemonic for IN operator:
https://comp.soft-sys.sas.narkive.com/O2Hj5ReW/pound-sign-causes-macro-problems-in-version-9-1
I went through that thread in link you posted. Two observations:
1) an %iiF() macrofunction pops-up there too
2) you took part in that discussion 🙂
B.
They had to fix %EVAL() to recognize IN as an operator or else it would never have worked at all.
That is because when you write something like
%if &x = 5 %then %do;
That is just an implied call to %EVAL() to evaluate the condition.
Seems like an oversight to me. It has worked that way since the concept of allowing IN as an operator in the macro language was introduced.
Is it something that needs to be fixed? Or just documented. Find the documentation page for %SYEVALF() on-line and click on the FEEDBACK button and send the SAS documentation team a request that they include the fact that it does not support IN as an operator.
They had to fix %EVAL() to recognize IN as an operator or else it would never have worked at all.
It seems like a massive oversight to forget to update %sysevalf() as well at the same time.
Thanks @yabwon . Interesting thread, and glad to have the input from others! Agree with you and others that this feels very buggy. I think it's worth reporting to SAS as a %SYSEVALF bug, and then they can decide whether to fix it or document it as a "feature." : )
Personally, the introduction of the IN operator to the macro language was so buggy for several versions, that I've stayed away from it. In the context of macro language IN bugs in prior versions, it's not too shocking for find another one.
I wrote to the SAS Support Team.
It was registered as: Case CS0080416
Will keep you updated.
@yabwon It might also be worth to provide feedback to the SAS Docu so this feature gets at least documented until fixed.
As Kurt and Tom said. %sysevalf() didn't honor IN operator .
Yes. You could report it to SAS to let it active like %eval().
%macro test3()/minoperator mindelimiter=' ';
%if %sysevalf( %eval(1.1 IN (1.1 2.1 3.1)) ) %then %put [&sysmacroname.] 123!!;
%mend;
%test3()
344 345 %macro test3()/minoperator mindelimiter=' '; 346 %if %sysevalf( %eval(1.1 IN (1.1 2.1 3.1)) ) %then %put [&sysmacroname.] 123!!; 347 %mend; 348 349 350 %test3() [TEST3] 123!!
I got information form SAS Tech. Support that R&D did not decide to fix the error.
They decided to update the documentation with something like: "The %SYSEVALF function does not support the IN logical operator in expression."
The updated doc. should be available within a month.
Bart
Since they are not fixing it perhaps they could also add into the %SYSEVALF() documentation the work around that @Ksharp posted.
Something like:
To use IN operator inside %SYSEVALF() you will have to use a call to %EVAL() inside your %SYSEVALF() expression.
Example:
%sysevalf( (&x > 1.3) and not %eval(&x in 999 NA N/A))
Good point, I'll share the idea.
Bart
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.