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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 665 views
  • 2 likes
  • 2 in conversation