DATA Step, Macro, Functions and more

"not in" Statement does not work in Macro?

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

"not in" Statement does not work in Macro?

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.


Accepted Solutions
Solution
‎10-16-2012 11:47 PM
Super Contributor
Posts: 1,636

Re: "not in" Statement does not work in Macro?

Posted in reply to MikeTurner

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


All Replies
Solution
‎10-16-2012 11:47 PM
Super Contributor
Posts: 1,636

Re: "not in" Statement does not work in Macro?

Posted in reply to MikeTurner

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

Contributor
Posts: 49

Re: "not in" Statement does not work in Macro?

Got it. Thanks

PROC Star
Posts: 7,487

Re: "not in" Statement does not work in Macro?

Posted in reply to MikeTurner

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 205 views
  • 0 likes
  • 3 in conversation