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

Hi All,

I was struggling to make my code works, but two issue hanging on there.  Here is my code:

=================

%MACRO TEST;

  %LET _DEBUG=0;

  %IF &_DEBUG=1 %THEN; %DO;

  %PUT THIS TIME DEBUG IS 1: _DEBUG=&_DEBUG;

  %END;

%MEND TEST;

%TEST;

===============

The output is not I was expecting:

=============

THIS TIME DEBUG IS 1: _DEBUG=0

=============

I changed my code to the following, more severe issue appear:

================

%MACRO TEST2;

  %LET _DEBUG=0;

  %IF &_DEBUG=1 %THEN; %DO;

  %PUT THIS TIME DEBUG IS 1: _DEBUG=&_DEBUG;

  %END;

  %ELSE %DO; 

  %PUT THIS TIME DEBUG IS NOT 1: _DEBUG=&_DEBUG;

  %END;

%MEND TEST2;

%TEST2;

The output is:

==============

90100   %MACRO TEST2;

90101       %LET _DEBUG=0;

90102

90103       %IF &_DEBUG=1 %THEN; %DO;

90104           %PUT THIS TIME DEBUG IS 1: _DEBUG=&_DEBUG;

90105       %END;

90106       %ELSE %DO;

ERROR: There is no matching %IF statement for the %ELSE. A dummy macro will be compiled.

90107           %PUT THIS TIME DEBUG IS NOT 1: _DEBUG=&_DEBUG;

90108       %END;

90109

90110   %MEND TEST2;

90111

90112   %TEST2;

        -

        180

WARNING: Apparent invocation of macro TEST2 not resolved.

ERROR 180-322: Statement is not valid or it is used out of proper order.

============

Anybody can help me with these two issues?

Thanks in Advance.

Abdu.

1 ACCEPTED SOLUTION

Accepted Solutions
Scott_Mitchell
Quartz | Level 8

You don't need a semi colon between your %THEN and %DO.


View solution in original post

2 REPLIES 2
Scott_Mitchell
Quartz | Level 8

You don't need a semi colon between your %THEN and %DO.


Abdu
Calcite | Level 5

Thank you, Scott.  I was screwed by this ";"

Abdu.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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