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

Hello, 

 

May you help with what is wrong about following macro?  Thank you.   -Ivy 

 

%macro t ;
%let group = 'SORAFENIB_1stline' ;

%if &group. in ( 'SORAFENIB_1stline' , 'commercial', 'Cirrhosis', 'meta') %then %do;
proc sql;
select count(distinct enrolid) into: cntt
from ads.cohort ;
quit;
%end;
%mend;

%t;

 

15 %macro t ;
16 %let group = 'SORAFENIB_1stline' ;
17
18 %if &group. in ( 'SORAFENIB_1stline' , 'commercial', 'Cirrhosis', 'meta') %then %do;
19 proc sql;
20 select count(distinct enrolid) into: cntt
21 from ads.cohort ;
22 quit;
23 %end;
24 %mend;
25
26 %t;
MLOGIC(T): Beginning execution.
MLOGIC(T): %LET (variable name is GROUP)
ERROR: Required operator not found in expression: &group. in ( 'SORAFENIB_1stline' , 'commercial', 'Cirrhosis', 'meta')
ERROR: The macro T will stop executing.
MLOGIC(T): Ending execution.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

MINOPERATOR

 

IN wasn't always supported in SAS macros, so when it was added to keep backwards compatibility it requires you to set the option.

 

You can check the docs on how the specifics work, but you can add it to your macro definition, which is the easiest option.

 

%macro t / MINOPERATOR;

View solution in original post

3 REPLIES 3
Reeza
Super User

MINOPERATOR

 

IN wasn't always supported in SAS macros, so when it was added to keep backwards compatibility it requires you to set the option.

 

You can check the docs on how the specifics work, but you can add it to your macro definition, which is the easiest option.

 

%macro t / MINOPERATOR;
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thank you very much, Reeza .
Astounding
PROC Star

In addition, you will need to specify what delimiter the IN operator should use.  A comma is permitted as the delimiter, but then you should not have spaces on either side of the commas in your %IF %THEN statement.  The name of the global option is MINDELIMITER:

 

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0vc5y2nyi55dvn1a...

 

And you will need to get rid of the parentheses around the list of items.  The macro language IN operator doesn't use them.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 1262 views
  • 2 likes
  • 3 in conversation