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