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

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

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;

SAS Innovate 2025: Register Now

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!

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
  • 1 reply
  • 874 views
  • 2 likes
  • 2 in conversation