DATA Step, Macro, Functions and more

List of macrovariables for IF THEN

Accepted Solution Solved
Reply
Regular Contributor
Posts: 210
Accepted Solution

List of macrovariables for IF THEN

Hi all,

 

Could you please say what is an equivalent of the following construction (that is not functioning):

 

%if &macrovariable in (A B C D E F) %then %do;
...
%end;

 

The syntax "in (A B C D E F)" is not functioning here. What is the correct one?  


Accepted Solutions
Solution
‎03-13-2018 06:58 AM
Super Contributor
Posts: 331

Re: List of macrovariables for IF THEN

Posted in reply to DmytroYermak

Hello,

 

The in operator  exists for macros but it has to be set with option minoperator :

 

option minoperator;

%macro test(macrovariable);

%if &macrovariable in (A B C D E F) %then %do;
%put Hello;
%end;
%else %do;
%put Sorry;
%end;


%mend;

%test(A);
%test(G);

View solution in original post


All Replies
Solution
‎03-13-2018 06:58 AM
Super Contributor
Posts: 331

Re: List of macrovariables for IF THEN

Posted in reply to DmytroYermak

Hello,

 

The in operator  exists for macros but it has to be set with option minoperator :

 

option minoperator;

%macro test(macrovariable);

%if &macrovariable in (A B C D E F) %then %do;
%put Hello;
%end;
%else %do;
%put Sorry;
%end;


%mend;

%test(A);
%test(G);
Regular Contributor
Posts: 210

Re: List of macrovariables for IF THEN

Thank you!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 68 views
  • 0 likes
  • 2 in conversation