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.
You don't need a semi colon between your %THEN and %DO.
Thank you, Scott. I was screwed by this ";"
Abdu.
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!
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.