Chapter Contents |
Previous |
Next |
%GLOBAL |
Type: | Macro statement |
Restriction: | Allowed in macro definitions or open code |
See also: | %LOCAL |
Syntax | |
Details | |
Comparisons | |
Example | |
Creating Global Variables in a Macro Definition |
Syntax |
%GLOBAL macro-variable(s); |
Details |
The %GLOBAL statement creates one or more global macro variables and assigns null values to the variables. Global macro variables are variables that are available during the entire execution of the SAS session or job.
A macro variable created with a %GLOBAL statement has a null value until you assign it some other value. If a global macro variable already exists and you specify that variable in a %GLOBAL statement, the existing value remains unchanged.
Comparisons |
Example |
%macro vars(first=1,last=); %global gfirst glast; %let gfirst=&first; %let glast=&last; var test&first-test&last; %mend vars;
When you submit the following program, the macro VARS generates the VAR statement and the values for the macro variables used in the title statement.
proc print; %vars(last=50) title "Analysis of Tests &gfirst-&glast"; run;
The SAS System sees the following:
PROC PRINT; VAR TEST1-TEST50; TITLE "Analysis of Tests 1-50"; RUN;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.