SAS Macro Language: Reference
What's New in the SAS 9 and 9.1 Macro Language Facility
Understanding and Using the Macro Facility
Introduction to the Macro Facility
Getting Started with the Macro Facility
Replacing Text Strings Using Macro Variables
Generating SAS Code Using Macros
More Advanced Macro Techniques
Other Features of the Macro Language
SAS Programs and Macro Processing
Introduction to SAS Programs and Macro Processing
How SAS Processes Statements without Macro Activity
How SAS Processes Statements with Macro Activity
Macro Variables
Introduction to Macro Variables
Macro Variables Defined by SAS
Macro Variables Defined by Users
Using Macro Variables
Displaying Macro Variable Values
Referencing Macro Variables Indirectly
Manipulating Macro Variable Values with Macro Functions
Macro Processing
Introduction to Macro Processing
Defining and Calling Macros
How the Macro Processor Compiles a Macro Definition
How the Macro Processor Executes a Compiled Macro
Summary of Macro Processing
Scopes of Macro Variables
Introduction to the Scopes of Macro Variables
Global Macro Variables
Local Macro Variables
Writing the Contents of Symbol Tables to the SAS Log
How Macro Variables Are Assigned and Resolved
Examples of Macro Variable Scopes
Macro Expressions
Introduction to Macro Expressions
Defining Arithmetic and Logical Expressions
How the Macro Processor Evaluates Arithmetic Expressions
How the Macro Processor Evaluates Logical Expressions
Macro Quoting
Introduction to Macro Quoting
Deciding When to Use a Macro Quoting Function and Which Function to Use
Using the %STR and %NRSTR Functions
Using the %BQUOTE and %NRBQUOTE Functions
Referring to Already Quoted Variables
Deciding How Much Text to Mask with a Macro Quoting Function
Using %SUPERQ
Summary of Macro Quoting Functions and the Characters They Mask
Unquoting Text
How Macro Quoting Works
Other Functions That Perform Macro Quoting
Interfaces with the Macro Facility
Introduction to Interfaces with the Macro Facility
DATA Step Interfaces
Using SAS Language Functions in the DATA Step and Macro Facility
Interfaces with the SQL Procedure
Interfaces with the SAS Component Language
SAS/CONNECT Interfaces
Storing and Reusing Macros
Introduction to Storing and Reusing Macros
Saving Macros in an Autocall Library
Saving Macros Using the Stored Compiled Macro Facility
Macro Facility Error Messages and Debugging
General Macro Debugging Information
Troubleshooting Your Macros
Debugging Techniques
Writing Efficient and Portable Macros
Introduction to Writing Efficient and Portable Macros
Keeping Efficiency in Perspective
Writing Efficient Macros
Writing Portable Macros
Macro Language Elements
Introduction to Macro Language Elements
Macro Statements
Macro Functions
Automatic Macro Variables
Interfaces with the Macro Facility
Selected Autocall Macros Provided with SAS Software
Selected System Options Used in the Macro Facility
Macro Language Dictionary
Macro Language Dictionary
%ABORT Statement
%BQUOTE and %NRBQUOTE Functions
CMDMAC System Option
%CMPRES and %QCMPRES Autocall Macros
%* Macro Comment Statement
%COMPSTOR Autocall Macro
%COPY Statement
%DATATYP Autocall Macro
%DISPLAY Statement
%DO Statement
%DO, Iterative Statement
%DO %UNTIL Statement
%DO %WHILE Statement
%END Statement
%EVAL Function
EXECUTE Routine
%GLOBAL Statement
%GOTO Statement
%IF-%THEN/%ELSE Statement
IMPLMAC System Option
%INDEX Function
%INPUT Statement
INTO Clause
%label Statement
%LEFT and %QLEFT Autocall Macro
%LENGTH Function
%LET Statement
%LOCAL Statement
%LOWCASE and %QLOWCASE Autocall Macros
%MACRO Statement
MACRO System Option
MAUTOLOCDISPLAY System Option
MAUTOSOURCE System Option
MCOMPILENOTE System Option
%MEND Statement
MERROR System Option
MFILE System Option
MINDELIMITER= System Option
MLOGIC System Option
MLOGICNEST System Option
MPRINT System Option
MPRINTNEST System Option
MRECALL System Option
MSTORED System Option
MSYMTABMAX= System Option
MVARSIZE= System Option
%NRBQUOTE Function
%NRQUOTE Function
%NRSTR Function
%PUT Statement
%QCMPRES Autocall Macro
%QLEFT Autocall
%QLOWCASE Autocall Macro
%QSCAN Function
%QSUBSTR Function
%QSYSFUNC Function
%QTRIM Autocall Macro
%QUOTE and %NRQUOTE Functions
%QUPCASE Function
RESOLVE Function
%RETURN Statement
SASAUTOS= System Option
SASMSTORE= System Option
%SCAN and %QSCAN Functions
SERROR System Option
%STR and %NRSTR Functions
%SUBSTR and %QSUBSTR Functions
%SUPERQ Function
SYMBOLGEN System Option
%SYMDEL Statement
SYMDEL Call Routine
%SYMEXIST Function
SYMEXIST Function
SYMGET Function
SYMGETN Function
%SYMGLOBL Function
SYMGLOBL Function
%SYMLOCAL Function
SYMLOCAL Function
SYMPUT Routine
SYMPUTN Routine
SYSBUFFR Automatic Macro Variable
%SYSCALL Statement
SYSCC Automatic Macro Variable
SYSCHARWIDTH Automatic Macro Variable
SYSCMD Automatic Macro Variable
SYSDATE Automatic Macro Variable
SYSDATE9 Automatic Macro Variable
SYSDAY Automatic Macro Variable
SYSDEVIC Automatic Macro Variable
SYSDMG Automatic Macro Variable
SYSDSN Automatic Macro Variable
SYSENV Automatic Macro Variable
SYSERR Automatic Macro Variable
%SYSEVALF Function
%SYSEXEC Statement
SYSFILRC Automatic Macro Variable
%SYSFUNC and %QSYSFUNC Functions
%SYSGET Function
SYSINDEX Automatic Macro Variable
SYSINFO Automatic Macro Variable
SYSJOBID Automatic Macro Variable
SYSLAST Automatic Macro Variable
SYSLCKRC Automatic Macro Variable
SYSLIBRC Automatic Macro Variable
%SYSLPUT Statement
SYSMACRONAME Automatic Macro Variable
SYSMENV Automatic Macro Variable
SYSMSG Automatic Macro Variable
SYSNCPU Automatic Macro Variable
SYSPARM Automatic Macro Variable
SYSPARM= System Option
SYSPBUFF Automatic Macro Variable
SYSPROCESSID Automatic Macro Variable
SYSPROCESSNAME Automatic Macro Variable
SYSPROCNAME Automatic Macro Variable
%SYSPROD Function
%SYSRC Autocall Macro
SYSRC Automatic Macro Variable
%SYSRPUT Statement
SYSSCP and SYSSCPL Automatic Macro Variables
SYSSCPL Automatic Macro Variable
SYSSITE Automatic Macro Variable
SYSSTARTID Automatic Macro Variable
SYSSTARTNAME Automatic Macro Variable
SYSTIME Automatic Macro Variable
SYSUSERID Automatic Macro Variable
SYSVER Automatic Macro Variable
SYSVLONG Automatic Macro Variable
%TRIM and %QTRIM Autocall Macro
%UNQUOTE Function
%UPCASE and %QUPCASE Functions
%VERIFY Autocall Macro
%WINDOW Statement
Appendixes
Reserved Words in the Macro Facility
Macro Facility Word Rules
Reserved Words
SAS Tokens
What Are SAS Tokens?
List of Tokens
Syntax for Selected Functions Used with the %SYSFUNC Function
Summary Descriptions and Syntax
Recommended Reading
Glossary
Introduction to the Macro Facility
Getting Started with the Macro Facility
Replacing Text Strings Using Macro Variables
Generating SAS Code Using Macros
More Advanced Macro Techniques
Other Features of the Macro Language
SAS Programs and Macro Processing
Introduction to SAS Programs and Macro Processing
How SAS Processes Statements without Macro Activity
How SAS Processes Statements with Macro Activity
Macro Processing
Introduction to Macro Processing
Defining and Calling Macros
How the Macro Processor Compiles a Macro Definition
How the Macro Processor Executes a Compiled Macro
Summary of Macro Processing
Introduction to Macro Variables
Macro Variables Defined by SAS
Macro Variables Defined by Users
Using Macro Variables
Displaying Macro Variable Values
Referencing Macro Variables Indirectly
Manipulating Macro Variable Values with Macro Functions
Scopes of Macro Variables
Introduction to the Scopes of Macro Variables
Global Macro Variables
Local Macro Variables
Writing the Contents of Symbol Tables to the SAS Log
How Macro Variables Are Assigned and Resolved
Examples of Macro Variable Scopes
Macro Expressions
Introduction to Macro Expressions
Defining Arithmetic and Logical Expressions
How the Macro Processor Evaluates Arithmetic Expressions
How the Macro Processor Evaluates Logical Expressions
Macro Quoting
Introduction to Macro Quoting
Deciding When to Use a Macro Quoting Function and Which Function to Use
Using the %STR and %NRSTR Functions
Using the %BQUOTE and %NRBQUOTE Functions
Referring to Already Quoted Variables
Deciding How Much Text to Mask with a Macro Quoting Function
Using %SUPERQ
Summary of Macro Quoting Functions and the Characters They Mask
Unquoting Text
How Macro Quoting Works
Other Functions That Perform Macro Quoting
Interfaces with the Macro Facility
Introduction to Interfaces with the Macro Facility
DATA Step Interfaces
Using SAS Language Functions in the DATA Step and Macro Facility
Interfaces with the SQL Procedure
Interfaces with the SAS Component Language
SAS/CONNECT Interfaces
Storing and Reusing Macros
Introduction to Storing and Reusing Macros
Saving Macros in an Autocall Library
Saving Macros Using the Stored Compiled Macro Facility
Macro Facility Error Messages and Debugging
General Macro Debugging Information
Troubleshooting Your Macros
Debugging Techniques
Writing Efficient and Portable Macros
Introduction to Writing Efficient and Portable Macros
Keeping Efficiency in Perspective
Writing Efficient Macros
Writing Portable Macros
Macro Language Elements
Introduction to Macro Language Elements
Macro Statements
Macro Functions
Automatic Macro Variables
Interfaces with the Macro Facility
Selected Autocall Macros Provided with SAS Software
Selected System Options Used in the Macro Facility