General form, MSTORED
system option:
OPTIONS MSTORED | NOMSTORED;
NOMSTORED
is the default setting,
and specifies that the Stored Compiled Macro Facility does not search
for compiled macros.
MSTORED
specifies that the
Stored Compiled Macro Facility searches for stored compiled macros
in a catalog in the SAS library that is referenced by the SASMSTORE=
option.
|
General form, SASMSTORE=
system option:
OPTIONS SASMSTORE=libref;
libref
specifies the libref
of a SAS library that contains, or contains, a catalog of stored compiled
SAS macros. This libref cannot be Work.
|
General form, macro
definition with STORE option:
%MACRO macro-name <(parameter-list)> /STORE
<DES='description'>;
text
%MEND <macro-name>;
description
is an optional 156-character
description that appears in the catalog directory.
macro-name
names the macro.
parameter-list
names one or more local
macro variables whose values you specify when you invoke the macro.
text
can be
|
%macro macro-name<(parameter list)> /STORE SOURCE;
Words
macro in compiled form
in a SAS library. This example shows the macro definition for Words
.
The macro takes a text string, divides it into words, and creates
a series of macro variables to store each word.
Words
is permanently stored
as a compiled macro and the macro source code is stored with it, as
follows: libname macrolib 'c:storedlib';
options mstored sasmstore=macrolib;
%macro words(text,root=w,delim=%str( ))/store source;
%local i word;
%let i=1;
%let word=%scan(&text,&i,&delim);
%do %while (&word ne );
%global &root&i;
%let &root&i=&word;
%let i=%eval(&i+1);
%let word=%scan(&text,&i,&delim);
%end;
%global &root.num;
%let &root.num=%eval(&i-1);
%mend words;
proc catalog cat=macrolib.sasmacr; contents; title "Stored Compiled Macros"; quit;
Words
macro. Assume that
the Words
macro was compiled and stored
in an earlier SAS session. libname macrolib 'c:storedlib'; options mstored sasmstore=macrolib; %words(This is a test) %put Number of Words (wnum): &wnum; %put Word Number 1 (w1): &w1; %put Word Number 2 (w2): &w2; %put Word Number 3 (w3): &w3; %put Word Number 4 (w4): &w4;
9 libname macrolib 'c:storedlib'; NOTE: Libref MACROLIB was successfully assigned as follows: Engine: V9 Physical Name: c:storedlib 10 options mstored sasmstore=macrolib; 11 12 %words(This is a test) 13 %put Number of Words (wnum): &wnum; Number of Words (wnum): 4 14 %put Word Number 1 (w1): &w1; Word Number 1 (w1): This 15 %put Word Number 2 (w2): &w2; Word Number 2 (w2): is 16 %put Word Number 3 (w3): &w3; Word Number 3 (w3): a 17 %put Word Number 4 (w4): &w4; Word Number 4 (w4): test |
General form, %COPY
statement:
%COPY macro-name /SOURCE <other
option(s)>;
macro-name
is the name of the
macro whose source code is accessed.
SOURCE
specifies that the
source code of the macro is copied to the output destination. If no
output destination is specified, the source is written to the SAS
log.
other options
include the following
options:
|
Words
.
libname macrolib 'c:storedlib'; options mstored sasmstore=macrolib; %macro words(text,root=w,delim=%str( ))/store source; %local i word; %let i=1; %let word=%scan(&text,&i,&delim); %do %while (&word ne ); %global &root&i; %let &root&i=&word; %let i=%eval(&i+1); %let word=%scan(&text,&i,&delim); %end; %global &root.num; %let &root.num=%eval(&i-1); %mend words;
Words
macro
to the SAS log. Here is an example: %copy words/source;
Words
macro.
17 %copy words/source; %macro words(text,root=w,delim=%str( ))/store source; %local i word; %let i=1; %let word=%scan(&text,&i,&delim); %do %while (&word ne ); %global &root&i; %let &root&i=&word; %let i=%eval(&i+1); %let word=%scan(&text,&i,&delim); %end; %global &root.num; %let &root.num=%eval(&i-1); %mend words; |
%words
, the macro processor searches for
the macro Words
as