Contents
About
Title Page
What's New in the SAS 9.3 Macro Language Facility
About This Book
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
SAS Programs and Macro Processing
How SAS Processes Statements without Macro Activity
How SAS Processes Statements with Macro Activity
Macro Variables
Macro Variables
Macro Variables Defined by the Macro Processor
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
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
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
Special Cases of Scope with the CALL SYMPUT Routine
Macro Expressions
Macro Expressions
Defining Arithmetic and Logical Expressions
How the Macro Processor Evaluates Arithmetic Expressions
How the Macro Processor Evaluates Logical Expressions
Macro Quoting
Macro Quoting
Deciding When to Use a Macro Quoting Function and Which Function to Use
%STR and %NRSTR Functions
%BQUOTE and %NRBQUOTE Functions
Referring to Already Quoted Variables
Deciding How Much Text to Mask with a Macro Quoting Function
%SUPERQ Function
Summary of Macro Quoting Functions and the Characters that They Mask
Unquoting Text
How Macro Quoting Works
Other Functions That Perform Macro Quoting
Interfaces with the Macro Facility
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
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
Writing Efficient and Portable Macros
Keeping Efficiency in Perspective
Writing Efficient Macros
Writing Portable Macros
Macro Language Elements
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
AutoCall Macros
AutoCall Macros
%CMPRES and %QCMPRES Autocall Macros
%COMPSTOR Autocall Macro
%DATATYP Autocall Macro
%KVERIFY Autocall Macro
%LEFT and %QLEFT Autocall Macro
%LOWCASE and %QLOWCASE Autocall Macros
%QCMPRES Autocall Macro
%QLEFT Autocall Macro
%QLOWCASE Autocall Macro
%QTRIM Autocall Macro
%SYSRC Autocall Macro
%TRIM and %QTRIM Autocall Macro
%VERIFY Autocall Macro
Automatic Macro Variables
Automatic Macro Variables
SYSADDRBITS Automatic Macro Variable
SYSBUFFR Automatic Macro Variable
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
SYSENCODING Automatic Macro Variable
SYSENDIAN Automatic Macro Variable
SYSENV Automatic Macro Variable
SYSERR Automatic Macro Variable
SYSERRORTEXT Automatic Macro Variable
SYSFILRC Automatic Macro Variable
SYSHOSTNAME Automatic Macro Variable
SYSINDEX Automatic Macro Variable
SYSINFO Automatic Macro Variable
SYSJOBID Automatic Macro Variable
SYSLAST Automatic Macro Variable
SYSLCKRC Automatic Macro Variable
SYSLIBRC Automatic Macro Variable
SYSLOGAPPLNAME Automatic Macro Variable
SYSMACRONAME Automatic Macro Variable
SYSMENV Automatic Macro Variable
SYSMSG Automatic Macro Variable
SYSNCPU Automatic Macro Variable
SYSNOBS Automatic Macro Variable
SYSODSESCAPECHAR Automatic Macro Variable
SYSODSPATH Automatic Macro Variable
SYSPARM Automatic Macro Variable
SYSPBUFF Automatic Macro Variable
SYSPROCESSID Automatic Macro Variable
SYSPROCESSNAME Automatic Macro Variable
SYSPROCNAME Automatic Macro Variable
SYSRC Automatic Macro Variable
SYSSCP and SYSSCPL Automatic Macro Variables
SYSSCPL Automatic Macro Variable
SYSSITE Automatic Macro Variable
SYSSIZEOFLONG Automatic Macro Variable
SYSSIZEOFPTR Automatic Macro Variable
SYSSIZEOFUNICODE Automatic Macro Variable
SYSSTARTID Automatic Macro Variable
SYSSTARTNAME Automatic Macro Variable
SYSTCPIPHOSTNAME Automatic Macro Variable
SYSTIME Automatic Macro Variable
SYSUSERID Automatic Macro Variable
SYSVER Automatic Macro Variable
SYSVLONG Automatic Macro Variable
SYSVLONG4 Automatic Macro Variable
SYSWARNINGTEXT Automatic Macro Variable
DATA Step Call Routines for Macros
DATA Step Call Routines for Macros
CALL EXECUTE Routine
CALL SYMDEL Routine
CALL SYMPUT Routine
CALL SYMPUTN Routine
CALL SYMPUTX Routine
DATA Step Functions for Macros
DATA Step Functions for Macros
RESOLVE Function
SYMEXIST Function
SYMGET Function
SYMGETN Function
SYMGLOBL Function
SYMLOCAL Function
Macro Functions
Macro Functions
%BQUOTE and %NRBQUOTE Functions
%EVAL Function
%INDEX Function
%LENGTH Function
%NRBQUOTE Function
%NRQUOTE Function
%NRSTR Function
%QSCAN Function
%QSUBSTR Function
%QSYSFUNC Function
%QUOTE and %NRQUOTE Functions
%QUPCASE Function
%SCAN and %QSCAN Functions
%STR and %NRSTR Functions
%SUBSTR and %QSUBSTR Functions
%SUPERQ Function
%SYMEXIST Function
%SYMGLOBL Function
%SYMLOCAL Function
%SYSEVALF Function
%SYSMACEXEC Function
%SYSMACEXIST Function
%SYSMEXECDEPTH Function
%SYSMEXECNAME Function
%SYSFUNC and %QSYSFUNC Functions
%SYSGET Function
%SYSPROD Function
%UNQUOTE Function
%UPCASE and %QUPCASE Functions
SQL Clauses for Macros
SQL Clauses for Macros
INTO Clause
Macro Statements
Macro Statements
%ABORT Statement
%* Macro Comment Statement
%COPY Statement
%DISPLAY Statement
%DO Statement
%DO, Iterative Statement
%DO %UNTIL Statement
%DO %WHILE Statement
%END Statement
%GLOBAL Statement
%GOTO Statement
%IF-%THEN/%ELSE Statement
%INPUT Statement
%label Statement
%LET Statement
%LOCAL Statement
%MACRO Statement
%MEND Statement
%PUT Statement
%RETURN Statement
%SYMDEL Statement
%SYSCALL Statement
%SYSEXEC Statement
%SYSLPUT Statement
%SYSMACDELETE Statement
%SYSMSTORECLEAR Statement
%SYSRPUT Statement
%WINDOW Statement
System Options for Macros
System Options for Macros
CMDMAC System Option
IMPLMAC System Option
MACRO System Option
MAUTOCOMPLOC System Option
MAUTOLOCDISPLAY System Option
MAUTOLOCINDES System Option
MAUTOSOURCE System Option
MCOMPILENOTE System Option
MCOMPILE System Option
MCOVERAGE System Options
MCOVERAGELOC= System Option
MERROR System Option
MEXECNOTE System Option
MEXECSIZE System Option
MFILE System Option
MINDELIMITER= System Option
MINOPERATOR System Option
MLOGIC System Option
MLOGICNEST System Option
MPRINT System Option
MPRINTNEST System Option
MRECALL System Option
MREPLACE System Option
MSTORED System Option
MSYMTABMAX= System Option
MVARSIZE= System Option
SASAUTOS= System Option
SASMSTORE= System Option
SERROR System Option
SYMBOLGEN System Option
SYSPARM= System Option
Appendices
Reserved Words in the Macro Facility
Macro Facility Word Rules
Reserved Words
SAS Tokens
SAS Tokens
List of Tokens
Syntax for Selected Functions Used with the %SYSFUNC Function
Summary Descriptions and Syntax
Functions and Arguments for %SYSFUNC
Recommended Reading
Glossary
Product
Release
Base SAS
9.3
Type
Usage and Reference
Copyright Date
July 2011
Last Updated
09Jun2011