Can I use MACRO language statements like %IF in open code?

Historically these MACRO language statements could only be used within a MACRO program definition which led to many developers contriving MACRO programs just to use such conditional logic.

This is no longer the case, and a simple conditional %IF-%THEN MACRO statement can now be used in open code:

*** These statements could always be used in open code *** ;
%let tstp = %sysfunc(today().worddate.) ;
%put &=tstp ;

*** This logic would historically have generated an ERROR *** ;
%if &tstp ne %then
%do ;
  %put NOTE: macro value is set to &tstp.. ;
%end ;

Submitting this code creates the desired NOTE in the LOG with no WARNINGs / ERRORs

Alan D Rudland
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category