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

I defined one macro variable VAR, then I wrote the codes as below;

%if %UPCASE(&VAR) NOT IN ("ABC", "XYZ") %THEN %DO;

BLABLABLA;

%END;

It seems incorrect,  is there one statement in MACRO equal to "not in" or "in" statement?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

you need to use option:

example:

options minoperator;

%if &state in (NY NJ PA) %then %let &region = %eval(&region + 1);

more detail at http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003092012.htm

View solution in original post

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

you need to use option:

example:

options minoperator;

%if &state in (NY NJ PA) %then %let &region = %eval(&region + 1);

more detail at http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003092012.htm

MikeTurner
Calcite | Level 5

Got it. Thanks

art297
Opal | Level 21

Actually, since you are using macro code, I think you will also need a macro option as well:

%let var=ABC;

options minoperator;

%macro test/mindelimiter=',';

  %if not(%upcase(&VAR) in (ABC,XYZ)) %THEN %DO;

    %put met condition;

  %END;

  %else %do;

    %put did not meet condition;

  %end;

%mend test;

%test

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2118 views
  • 0 likes
  • 3 in conversation