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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.