Hi,
I am using below code to identiy the yyyymm in old vs new path. I am getting %EVAL error, could someone help me with it.
%macro comp(yyyymm); %let new_path = /sas/Prod/Data/July21/&yyyymm.; %if %eval(&yyyymm. IN 200701 200704 200810 200905 200906 200911 200912 201005 201006 201011 201012 201205 201206 201209 201408 201409 201410 201411 201412)|(&yyyymm. >= 201704 & &yyyymm. <= 202008) %then %do; %let old_path = /sas/Prod/&yyyymm.; %end; %else %if &yyyymm. = 200808 | &yyyymm. = 200809 | (&yyyymm. >= 201301 & &yyyymm. <= 201612) | (&yyyymm. >= 201701 & &yyyymm. <= 201703) %then %do; %let old_path = /sas/Prod/BT/&yyyymm.; %end; %else %do; %let old_path = /sas/Prod/Repair/&yyyymm.; %end; LIBNAME N&yyyymm. "&new_path." access=readonly; LIBNAME O&yyyymm. "&old_path."; %mend; %comp(200701);
error :
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
200701 IN 200701 200704 200810 200905 200906 200911 200912 201005 201006 201011 201012 201205 201206 201209 201408
201409 201410 201411 201412
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
%eval(&yyyymm. IN 200701 200704 200810 200905 200906 200911 200912 201005 201006 201011 201012 201205 201206 201209
201408 201409 201410 201411 201412)|(&yyyymm. >= 201704 & &yyyymm. <= 202008)
2 The SAS System 11:15 Monday, July 5, 2021
ERROR: The macro COMP will stop executing.
Please verify that minoperator is active.
As always i recommend to write code without macro-statements and after the code has been tested, create a macro if necessary.
If the option minoperator is active in your sas session, you could use
%if &yyyymm. in (200701 200704 ....) %then %do; ...
Please verify that minoperator is active.
As you probably know, the IN operator can be tricky in macro language. Global options have to be properly in place, and properly utilized in your code.
Before getting to that point, get rid of %EVAL. It serves no purpose in your code, and just complicates the logic. It is likely that %EVAL would not even be the correct function, and you would need to switch to %SYSEVALF. But you actually can get by with neither.
Hi @vnreddy,
As @andreas_lds has advised, one way to check the minoperator (allows you to use the in operator in a macro) is:
proc options option=minoperator;
run;
As you are only using logic, the %eval is not required. If you don't want to change the global value of the minoperator option, then you can specify it as an option on the %macro statement.
%macro comp(yyyymm) / minoperator;
More information can be found in the documentation:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nypovnwon4uyn159rst8pgzqrl.htm
Kind regards,
Amir.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.