Chapter Contents |
Previous |
Next |
EXECUTE |
Type: | DATA step routine |
Syntax | |
Details | |
Comparisons | |
Examples | |
Example 1: Executing a Macro Conditionally | |
Example 2: Passing DATA Step Values Into a Parameter List |
Syntax |
CALL EXECUTE (argument); |
call execute('%sales');
call execute(findobs);
call execute('%sales('||month||')');
Details |
If an EXECUTE routine argument is a macro invocation or resolves to one, the macro executes immediately. However, any SAS statements produced by the EXECUTE routine do not execute until after the step boundary has been passed.
Note: Because 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.
See Chapter 8, "Interfaces with the Macro Facility," in SAS Macro Language: Reference,
for an example.
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 |
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 do; n+1; output; end; if final and n then call execute('%overdue'); run;
CALL EXECUTE passes the value of the DATE variable in the DATES data set to macro REPT for its DAT parameter, the value of the VAR1 variable in the REPTDATA data set for its A parameter, and REPTDATA as the value of its DSN parameter. After the DATA _NULL_ step finishes, three PROC GCHART statements are submitted, one for each of the three dates in the DATES data set.
data dates; input date $; cards; 10nov97 11nov97 12nov97 ; data reptdata; input date $ var1 var2; cards; 10nov97 25 10 10nov97 50 11 11nov97 23 10 11nov97 30 29 12nov97 33 44 12nov97 75 86 ; %macro rept(dat,a,dsn); proc chart data=&dsn; title "Chart for &dat"; where(date="&dat"); vbar &a; run; %mend rept; data _null_; set dates; call execute('%rept('||date||','||'var1,reptdata)'); run;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.