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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: