Macro Statements |
Type: | Macro statement |
Restriction: | Allowed in macro definitions only |
See also: | %GOTO Statement |
Syntax | |
Details | |
Example | |
Controlling Program Flow |
Syntax |
%label: macro-text |
specifies a SAS name.
is a macro statement, a text expression, or constant text. The following examples illustrate each:
Details |
The label name is preceded by a %. When you specify this label in a %GOTO statement, do not precede it with a %.
An alternative to using the %GOTO statement and statement label is to use a %IF-%THEN statement with a %DO group.
Example |
In the macro INFO, the %GOTO statement causes execution to jump to the label QUICK when the macro is invoked with the value of short for the parameter TYPE.
%macro info(type); %if %upcase(&type)=SHORT %then %goto quick; /* No % here */ proc contents; run; proc freq; tables _numeric_; run; %quick: proc print data=_last_(obs=10); /* Use % here */ run; %mend info; %info(short)
Invoking the macro INFO with TYPE equal to short generates these statements:
PROC PRINT DATA=_LAST_(OBS=10); RUN;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.