DATA Step, Macro, Functions and more

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

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

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

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.


Accepted Solutions
Solution
‎11-02-2014 10:57 PM
Super Contributor
Posts: 297

Re: %IF &_DEBUG=1 %THEN; %DO; ISSUES

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


View solution in original post


All Replies
Solution
‎11-02-2014 10:57 PM
Super Contributor
Posts: 297

Re: %IF &_DEBUG=1 %THEN; %DO; ISSUES

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


Contributor
Posts: 35

Re: %IF &_DEBUG=1 %THEN; %DO; ISSUES

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

Abdu.

🔒 This topic is solved and locked.

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

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