【SAS】SAS MACRO CODE學習筆記

Defining a Macro:
%MACRO macro-name;
macro-text
%MEND macro-name;

---------------------------------------------------------
Monitoring Compilation:
OPTION MCOMPILENOTE=ALL | NONE;
---------------------------------------------------------

Calling a Macro:
%macro-name
---------------------------------------------------------

Monitoring Execution:
OPTIONS MPRINT;(可以在log秀出程式)
OPTIONS NOMPRINT;(Default)

OPTIONS MLOGIC;(秀出執行MACRO過程的訊息)
OPTIONS NOMLOGIC;(Default)
---------------------------------------------------------

Comments in Macro Programs:
%* comment;(不會執行的註解,在MPRINT中也不會秀出來)
---------------------------------------------------------

Macro Parameter Lists:
%MACRO macro-name(parameter list);
text referencing parameter variables
%MEND;

%MACRO-NAME(parameter-values)
---------------------------------------------------------

Macros with Positional Parameters:
%MACRO macro-name(positional-1,...,positional-n);
text referencing parameter variables
%MEND;

%macro-name(value-1,...,value-n)
---------------------------------------------------------

Macros with Keyword Parameters:
%macro-name(keyword=value,...,keyword=value)
---------------------------------------------------------

Macros with Mixed Parameter Lists:
%MACRO macro-name(positional-1,...,postional-n,
keyword=value,...,keyword=value);
text referencing parameter variables
%MEND;
---------------------------------------------------------
Conditional Execution:
%IF expression %THEN text;
%ELSE text;

%IF expression %THEN %DO;
statement;statement;...
%END;
%ELSE %DO;
statement;statement;...
%END;
---------------------------------------------------------
Simple Loops:
%DO index-variable=start %TO stop %BY increment;
text
%END;

留言

熱門文章