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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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