I have the following code (not identical but it captures the question):
%let country = SE;
%IF &country. in (SE NO USA) %THEN %DO;
data MyTable1;
run;
%END;
%IF &country. = UK %THEN %DO;
data MyTable2;
run;
%END;
Running this code yields the error:
ERROR: Required operator not found in expression: SE in (SE NO USA)
ERROR: Skipping to next %END statement.
Any ideas why this error occurs and how I can solve it?
If you want to use IN as an operator in macro code you need to tell it so.
Use the MINOPERATOR option and the MINDELIMITER= option to tell SAS that you want to use IN as an operator.
If you are using this inside a macro definition use the MINOPERATOR and MINDELIMITER= options on the %MACRO statement.
165 options minoperator mindelimiter=' ';
166
167 %let country = SE;
168
169 %IF &country. in SE NO USA %THEN %DO;
170 %put &=country in list.;
COUNTRY=SE in list.
171 %END;
If you want to use IN as an operator in macro code you need to tell it so.
Use the MINOPERATOR option and the MINDELIMITER= option to tell SAS that you want to use IN as an operator.
If you are using this inside a macro definition use the MINOPERATOR and MINDELIMITER= options on the %MACRO statement.
165 options minoperator mindelimiter=' ';
166
167 %let country = SE;
168
169 %IF &country. in SE NO USA %THEN %DO;
170 %put &=country in list.;
COUNTRY=SE in list.
171 %END;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.