Hi , this reminds me my first time to use Macro, I didn't understand the difference between %if -%then and if- then
kindly find my findings:
1. '%if-%then' can ONLY be used in the MACRO program (whether inside the DATA step, or outside) and 'if-then' is ONLY used inside the DATA step (whether MACRO or non-MACRO).
2.In the DATA step, you can use 'if alone to do logical comparison. But you can not use '%if alone. You also can not use '%else' alone without '%do; %end' pair.
3.'%if-%then' uses MACRO variables in logical expressions and can not refer to DATA step variables in logical expressions (you can not write: %if x=l %then %do; because x is not a MACRO variable), while 'if-then' can use MACRO variables or use DATA step variables in logical expressions.
4.'%if-%then' in MACRO determines what text should be copied to the input stack. When you use 'if-then' inside a MACRO (or non-MACRO), it does logical comparison to determine what DATA step statements should be executed.
Hope this helps, thanks@_el_doredo
... View more