DATA Step, Macro, Functions and more

%if with and

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

%if with and

Hi, all

Does anybody know why we can't do something like the example below:

"%if &x = 1 and &y = 2 %then %do;"

Question:

Is not possible put "and" in the "%if" condition ?


Accepted Solutions
Solution
‎06-03-2013 03:40 PM
Super User
Posts: 19,792

Re: %if with and

9%LET X=1;

10   %LET Y=2;

11   %MACRO TEST;

12

13   %IF &X=1 AND &Y=2 %THEN %DO;

14  %PUT PASS;

15   %END;

16   %ELSE %PUT FAIL;

17

18   %MEND;

19

20   %TEST;

PASS

You can, there's something else wrong in your program.

View solution in original post


All Replies
Solution
‎06-03-2013 03:40 PM
Super User
Posts: 19,792

Re: %if with and

9%LET X=1;

10   %LET Y=2;

11   %MACRO TEST;

12

13   %IF &X=1 AND &Y=2 %THEN %DO;

14  %PUT PASS;

15   %END;

16   %ELSE %PUT FAIL;

17

18   %MEND;

19

20   %TEST;

PASS

You can, there's something else wrong in your program.

Contributor
Posts: 46

Re: %if with and

Tk's Reeza, it was something wrong in my program.

🔒 This topic is solved and locked.

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

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