• the name of a DATA step character variable whose value is a text expression or a
SAS statement to be generated. Do not enclose the name of the DATA step
variable in quotation marks. For example, to use the value of the DATA step
variable FINDOBS, which contains a SAS statement or text expression, you can
use the following code:
call execute(findobs);
• a character expression that is resolved by the DATA step to a macro text
expression or a SAS statement. For example, to generate a macro invocation
whose parameter is the value of the variable MONTH, you use the following
code:
call execute('%sales('||month||')');
Details
If an EXECUTE routine argument is a macro invocation or resolves to one, the macro
executes immediately. Execution of SAS statements generated by the execution of the
macro will be delayed until after a step boundary. SAS macro statements, including
macro variable references, will execute immediately.
Note: Because of the delay of the execution of the SAS statements until after a step
boundary, references in SAS macro statements to macro variables created or updated
by the SAS statements will not resolve properly.
Note: Macro references execute immediately and SAS statements do not execute until
after a step boundary. You cannot use CALL EXECUTE to invoke a macro that
contains references for macro variables that are created by CALL SYMPUT in that
macro. For a workaround, see the following TIP.
T I P The following example uses the %NRSTR macro quoting function to mask the
macro statement. This function will delay the execution of macro statements until
after a step boundary.
call execute('%nrstr(%sales('||month||'))');
Comparisons
Unlike other elements of the macro facility, a CALL EXECUTE statement is available
regardless of the setting of the SAS system option MACRO | NOMACRO. In both cases,
EXECUTE places the value of its argument in the program stack. However, when
NOMACRO is set, any macro calls or macro functions in the argument are not resolved.
Examples
Example 1: Executing a Macro Conditionally
The following DATA step uses CALL EXECUTE to execute a macro only if the DATA
step writes at least one observation to the temporary data set.
%macro overdue;
proc print data=late;
title "Overdue Accounts As of &sysdate";
run;
%mend overdue;
data late;
set Sasuser.Billed end=final;
if datedue<=today()-30 then
238 Chapter 15 • DATA Step Call Routines for Macros