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

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
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

2 REPLIES 2
Reeza
Super User
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.

Abud
Calcite | Level 5

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 1114 views
  • 0 likes
  • 2 in conversation