Home Page Icon
Home Page
Table of Contents for
Dictionary (11/11)
Close
Dictionary (11/11)
by
SAS 9.4 Macro Language, 5th Edition
Contents
What’s New in the SAS 9.4 Macro Facility
Overview
SAS Macro Facility Error and Warning Messages
SAS Macro Examples
New Automatic Macro Variables
New Options for Macro Statements
Enhancements to Macro System Options
Understanding and Using the Macro Facility
Introduction to the Macro Facility
Getting Started with the Macro Facility
Using the Macro Facility in SAS Viya
Replacing Text Strings Using Macro Variables
Generating SAS Code Using Macros
Defining Macros
Inserting Comments in Macros
Macro Definition Containing Several SAS Statements
Passing Information into a Macro Using Parameters
Conditionally Generating SAS Code
More Advanced Macro Techniques
Generating Repetitive Pieces of Text Using %DO Loops
Generating a Suffix for a Macro Variable Reference
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
Overview for Defining Macro Variables
Creating User-Defined Macro Variable Names
Assigning Values to Macro Variables
Using Macro Variables
Macro Variable Reference
Combining Macro Variable References with Text
Delimiting Macro Variable Names within Text
Creating a Period to Follow Resolved Text
Displaying Macro Variable Values
Referencing Macro Variables Indirectly
Using an Expression to Generate a Reference
Generating a Series of Macro Variable References with a Single Macro Call
Using More Than Two Ampersands
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 (1/2)
How the Macro Processor Executes a Compiled Macro (2/2)
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 (1/2)
Examples of Macro Variable Scopes (2/2)
Changing the Values of Existing Macro Variables
Creating Local Variables
Forcing a Macro Variable to Be Local
Creating Global Macro Variables
Creating Global Variables Based on the Value of Local Variables
Special Cases of Scope with the CALL SYMPUT Routine (1/2)
Special Cases of Scope with the CALL SYMPUT Routine (2/2)
Overview of CALL SYMPUT Routine
Example Using CALL SYMPUT with Complete DATA Step and a Nonempty Local Symbol Table
Example Using CALL SYMPUT with an Incomplete DATA Step
Example Using CALL SYMPUT with a Complete DATA Step and an Empty Local Symbol Table
Example Using CALL SYMPUT with SYSPBUFF and an Empty Local Symbol Table
Macro Expressions
Macro Expressions
Defining Arithmetic and Logical Expressions
Evaluating Arithmetic and Logical Expressions
Operands and Operators
How the Macro Processor Evaluates Arithmetic Expressions
Evaluating Numeric Operands
Evaluating Floating-Point Operands
How the Macro Processor Evaluates Logical Expressions
Comparing Numeric Operands in Logical Expressions
Comparing Floating-Point or Missing Values
Comparing Character Operands in Logical Expressions
Macro Quoting
Macro Quoting
Masking Special Characters and Mnemonics
Understanding Why Macro Quoting Is Necessary
Overview of Macro Quoting Functions
Passing Parameters That Contain Special Characters and Mnemonics
Deciding When to Use a Macro Quoting Function and Which Function to Use
%STR and %NRSTR Functions
Using %STR and %NRSTR Functions
Using Unmatched Quotation Marks and Parentheses with %STR and %NRSTR
Using % Signs with %STR
Examples Using %STR
Examples Using %NRSTR
%BQUOTE and %NRBQUOTE Functions
Using %BQUOTE and %NRBQUOTE Functions
Examples Using %BQUOTE
Referring to Already Quoted Variables
Deciding How Much Text to Mask with a Macro Quoting Function
%SUPERQ Function
Using %SUPERQ
Examples Using %SUPERQ
Using the %SUPERQ Function to Prevent Warning Messages
Using the %SUPERQ Function to Enter Macro Keywords
Summary of Macro Quoting Functions and the Characters That They Mask
Unquoting Text
Restoring the Significance of Symbols
Example of Unquoting
What to Do When Automatic Unquoting Does Not Work
How Macro Quoting Works
Other Functions That Perform Macro Quoting
Functions That Start with the Letter Q
Example Using the %QSCAN Function
Interfaces with the Macro Facility
Interfaces with the Macro Facility
DATA Step Interfaces
Interacting with the Macro Facility during DATA Step Execution
CALL EXECUTE Routine Timing Details
Example of Using CALL EXECUTE Incorrectly
Example of Common Problem with CALL EXECUTE
Using SAS Language Functions in the DATA Step and Macro Facility
Interfaces with the SQL Procedure
Using PROC SQL
INTO Clause
Controlling Job Execution
Interfaces with the SAS Component Language
Using an SCL Program
How Macro References Are Resolved by SCL
Referencing Macro Variables in Submit Blocks
Considerations for Sharing Macros between SCL Programs
Example Using Macros in an SCL Program
SAS/CONNECT Interfaces
Overview of SAS/CONNECT Interfaces
Using %SYSRPUT with SAS/CONNECT
Example Using %SYSRPUT to Check the Value of a Return Code on a Remote Host
Using %SYSLPUT with SAS/CONNECT
Example Using %SYSLPUT
Storing and Reusing Macros
Storing and Reusing Macros
Saving Macros in an Autocall Library
Overview of an Autocall Library
Using Directories as Autocall Libraries
Using SAS Catalogs as Autocall Libraries
Calling an Autocall Macro
Saving Macros Using the Stored Compiled Macro Facility
Overview of the Stored Compiled Macro Facility
Compiling and Storing a Macro Definition
Storing Autocall Macros Supplied by SAS
Calling a Stored Compiled Macro
Macro Facility Error Messages and Debugging
General Macro Debugging Information
Developing Macros in a Layered Approach
Encountering Errors
Developing Bug-free Macros
Troubleshooting Your Macros (1/3)
Troubleshooting Your Macros (2/3)
Troubleshooting Your Macros (3/3)
Solving Common Macro Problems
Solving Macro Variable Resolution Problems
Solving Problems with Macro Variable Scope
Solving Open Code Statement Recursion Problems
Solving Problems with Macro Functions
Solving Unresolved Macro Problems
Solving the “Black Hole” Macro Problem
Resolving Timing Issues
Example of a Macro Statement Executing Immediately
Resolving Macro Resolution Problems Occurring during DATA Step Compilation
Solving Problems with the Autocall Facility
Fixing Autocall Library Specifications
Fixing Autocall Macro Definition Errors
File and Macro Names for Autocall
Displaying Information about Stored Compiled Macros
Solving Problems with Expression Evaluation
Debugging Techniques (1/2)
Debugging Techniques (2/2)
Using System Options to Track Problems
Tracing the Flow of Execution with MLOGIC
Nesting Information Generated by MLOGICNEST
Examining the Generated SAS Statements with MPRINT
Nesting Information Generated by MPRINTNEST
Storing MPRINT Output in an External File
Examining Macro Variable Resolution with SYMBOLGEN
Using the %PUT Statement to Track Problems
Writing Efficient and Portable Macros
Writing Efficient and Portable Macros
Keeping Efficiency in Perspective
Writing Efficient Macros
Use Macros Wisely
Use Name Style Macros
Avoid Nested Macro Definitions
Assign Function Results to Macro Variables
Turn Off System Options When Appropriate
Use the Stored Compiled Macro Facility
Centrally Store Autocall Macros
Other Useful Efficiency Tips
Storing Only One Copy of a Long Macro Variable Value
Writing Portable Macros (1/2)
Writing Portable Macros (2/2)
Using Portable SAS Language Functions with %SYSFUNC
Example Using %SYSFUNC
Using Automatic Variables with Host-Specific Values
Example Using SYSPARM
SYSPARM Details
SYSRC Details
Macro Language Elements with System Dependencies
Host-Specific Macro Variables
Naming Macros and External Files for Use with the Autocall Facility
Macro Language Elements
Macro Language Elements
Macro Statements
Using Macro Statements
Macro Statements That Perform Automatic Evaluation
Macro Functions (1/2)
Macro Functions (2/2)
Using Macro Functions
Macro Character Functions
Macro Evaluation Functions
Macro Quoting Functions
Compilation Quoting Functions
Execution of Macro Quoting Functions
Quotation Marks and Parentheses without a Match
Macro Functions for Double-Byte Character Set (DBCS)
Other Macro Functions
Automatic Macro Variables
Interfaces with the Macro Facility
Selected Autocall Macros Provided with SAS Software
Overview of Provided Autocall Macros
Required System Options for Autocall Macros
Using Autocall Macros
Autocall Macros for Double-Byte Character Set (DBCS)
Selected System Options Used in the Macro Facility
Macro Language Dictionary
AutoCall Macros
AutoCall Macros
Dictionary
%CMPRES and %QCMPRES Autocall Macros
%COMPSTOR Autocall Macro
%DATATYP Autocall Macro
%KVERIFY Autocall Macro
%LEFT 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
Dictionary
SYSADDRBITS Automatic Macro Variable
SYSBUFFR Automatic Macro Variable
SYSCC Automatic Macro Variable
SYSCHARWIDTH Automatic Macro Variable
SYSCMD Automatic Macro Variable
SYSDATASTEPPHASE Automatic Macro Variable
SYSDATE Automatic Macro Variable
SYSDATE9 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
SYSHOSTINFOLONG Automatic Macro Variable
SYSHOSTNAME Automatic Macro Variable
SYSINCLUDEFILEDEVICE Automatic Macro Variable
SYSINCLUDEFILEDIR Automatic Macro Variable
SYSINCLUDEFILEFILEREF Automatic Macro Variable
SYSINCLUDEFILENAME 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
SYSMAXLONG 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
SYSPRINTTOLIST Automatic Macro Variable
SYSPRINTTOLOG Automatic Macro Variable
SYSPROCESSID Automatic Macro Variable
SYSPROCESSMODE 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
SYSTIMEZONE Automatic Macro Variable
SYSTIMEZONEIDENT Automatic Macro Variable
SYSTIMEZONEOFFSET 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
Dictionary
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
Dictionary
RESOLVE Function
SYMEXIST Function
SYMGET Function
SYMGETN Function
SYMGLOBL Function
SYMLOCAL Function
Macro Functions
Macro Functions
Dictionary (1/8)
Dictionary (2/8)
Dictionary (3/8)
Dictionary (4/8)
Dictionary (5/8)
Dictionary (6/8)
Dictionary (7/8)
Dictionary (8/8)
%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
%SYSFUNC and %QSYSFUNC Functions
%SYSGET Function
%SYSMACEXEC Function
%SYSMACEXIST Function
%SYSMEXECDEPTH Function
%SYSMEXECNAME Function
%SYSPROD Function
%UNQUOTE Function
%UPCASE and %QUPCASE Functions
SQL Clauses for Macros
SQL Clauses for Macros
Dictionary
INTO Clause
Macro Statements
Macro Statements
Dictionary (1/11)
Dictionary (2/11)
Dictionary (3/11)
Dictionary (4/11)
Dictionary (5/11)
Dictionary (6/11)
Dictionary (7/11)
Dictionary (8/11)
Dictionary (9/11)
Dictionary (10/11)
Dictionary (11/11)
%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
Dictionary (1/7)
Dictionary (2/7)
Dictionary (3/7)
Dictionary (4/7)
Dictionary (5/7)
Dictionary (6/7)
Dictionary (7/7)
CMDMAC System Option
IMPLMAC System Option
MACRO System Option
MAUTOCOMPLOC System Option
MAUTOLOCDISPLAY System Option
MAUTOLOCINDES System Option
MAUTOSOURCE System Option
MCOMPILE System Option
MCOMPILENOTE System Option
MCOVERAGE System Options
MCOVERAGELOC= System Option
MERROR 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
Appendixes
Reserved Words in the Macro Facility
Macro Facility Word Rules
Reserved Words
SAS Macro Facility Error and Warning Messages
SAS Macro Error Messages
SAS Macro Warning Messages (1/2)
SAS Macro Warning Messages (2/2)
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
SAS Macro Examples
Example 1: Import All CSV Files That Exist within a Directory
Details
Program
Program Description
Example 2: List All Files within a Directory Including Subdirectories
Details
Program
Program Description
Example 3: How to Increment a Macro DO Loop by a Non-integer Value
Details
Program
Program Description
Example 4: How to Use Character Values on a Macro %DO Loop
Details
Program
Program Description
Logs
Example 5: Place All SAS Data Set Variables into a Macro Variable
Details
Program
Program Description
Log
Example 6: How to Retrieve the Program Name That Is Currently Running in Batch Mode or Interactively
Details
Program
Program Description
Example 7: Using a Macro to Create New Variable Names from Variable Values
Details
Program
Program Description
Log
Output
Example 8: Dynamically Determine the Number of Observations and Variables in a SAS Data Set
Details
Program
Program Description
Log
Example 9: Use Macro Logic to Determine If an External File Is Empty
Details
Program
Program Description
Example 10: Retrieve Each Word from a Macro Variable List
Details
Program
Program Description
Output
Example 11: Loop through Dates Using a Macro %DO Loop
Details
Program
Program Description
Log
Example 12: Using Macro Variables within a CARDS or DATALINES Statement
Details
Program
Program Description
Output
Example 13: Print Information to the Output Window If a Data Set Is Empty
Details
Program
Program Description
Output
Example 14: Create a Quoted List Separated by Spaces
Details
Program
Program Description
Log Output
Example 15: Delete a File on UNIX or Windows If It Exists
Details
Program
Program Description
Example 16: Retrieve the File Size, Create Time, and Last Modified Date of an External File
Details
Program
Program Description
Example 17: Delete All User-defined Macro Variables
Details
Program
Program Description
Recommended Reading
Glossary (1/2)
Glossary (2/2)
Index (1/4)
Index (2/4)
Index (3/4)
Index (4/4)
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Dictionary (10/11)
Next
Next Chapter
System Options for Macros
352
Chapter 19
•
Macro Statements
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset