In this
example, the CALL EXECUTE routine is used incorrectly:
data prices; /* ID for price category and actual price */
input code amount;
datalines;
56 300
99 10000
24 225
;
%macro items;
%global special;
%let special=football;
%mend items;
data sales; /* incorrect usage */
set prices;
length saleitem $ 20;
call execute('%items');
saleitem="&special";
run;
In the DATA SALES step,
the assignment statement for SALEITEM requires the value of the macro
variable SPECIAL at DATA step compilation. CALL EXECUTE does not produce
the value until DATA step execution. Thus, you receive a message about
an unresolved macro variable, and the value assigned to SALEITEM is
&special
.
In this example, it
would be better to eliminate the macro definition (the %LET macro
statement is valid in open code) or move the DATA SALES step into
the macro ITEMS. In either case, CALL EXECUTE is not necessary or
useful. Here is one version of this program that works:
data prices; /* ID for price category and actual price */
input code amount;
datalines;
56 300
99 10000
24 225
;
%let special=football; /* correct usage */
data sales;
set prices;
length saleitem $ 20;
saleitem="&special";
run;
The %GLOBAL statement
is not necessary in this version. Because the %LET statement is executed
in open code, it automatically creates a global macro variable.
(See Scopes of Macro Variables for more information
about macro variable scopes.)