Apply Logic (from Fraktal SAS Programming)
Implementing MACRO logic is quite comparable to other languages, except that SAS requires so-called MACRO Triggers ("TRIGGERS"”) to direct processing to the appropriate subsystem inside the SAS ecosystem. These are:
& – the ampersand: indicates parameter reference
% - the percent sign: indicates syntax elements
TRIGGERS have been found necessary in the early history of SAS since the SAS Macro Facility was intended to perform text processing before code was sent to the SAS compiler. To invoke the text pre-processor every token is checked whether its 1st digit is a TRIGGER.
Of course the segment structure of coding also applies here:
%IF %LENGTH(&PARM_I.) ne 0 %THEN %DO; program code %END; %ELSE %DO; alternate program code %END;
Depending on whether a value is supplied in parameter PARM_I either "program code" or "alternate program code" is passed to the SAS compiler for processing.