Book description
Need help understanding the SAS macro facility? You will find all the answers that you need in this easy-to-follow book! Michele Burlew puts her decades of macro programming experience to work for you as she guides you through the basics, as well as the more complex features of the SAS macro facility. Updated extensively for SAS 9, this book includes plenty of examples and step-by-step instructions. You will learn the elements of the macro facility (macro variables, macro programs, macro language), how to write a macro program, macro programming techniques, tips on using the macro facility, how the macro facility fits into SAS, and about the interfaces between the macro facility and other components of SAS.
New topics for the second edition include using SAS 9 macro and SAS language features, debugging macro programs, adding error checking to macro programs, and building a library of utility macro programs.
Beginning macro programmers will learn to write SAS macro programs quickly and efficiently. More experienced macro programmers will find this book useful to refresh their conceptual knowledge and expand on their macro programming skills. It is also important to note that the macro facility is a highly popular part of SAS and found in the job requirements for many SAS programming jobs. In addition, macro facility concepts are tested on the SAS Advanced Programming Exam. The book assumes some SAS programming experience, including knowledge of how to write a DATA step and how to use SAS procedures.
Table of contents
- Copyright
- Praise from the Experts
- Preface
- Acknowledgments
-
1. Understanding the Concepts and Features of Macro Programming
- 1. Introduction
- 2. Mechanics of Macro Processing
-
3. Macro Variables
- Introduction
- Basic Concepts of Macro Variables
- Referencing Macro Variables
- Understanding Macro Variable Resolution and the Use of Single and Double Quotation Marks
- Displaying Macro Variable Values
- Understanding Automatic Macro Variables
- Understanding User-Defined Macro Variables
- Combining Macro Variables with Text
- Referencing Macro Variables Indirectly
-
4. Macro Programs
- Introduction
- Creating Macro Programs
- Executing a Macro Program
- Displaying Notes about Macro Program Compilation in the SAS Log
- Displaying Messages about Macro Program Processing in the SAS Log
- Passing Values to a Macro Program through Macro Parameters
- 5. Understanding Macro Symbol Tables and the Processing of Macro Programs
-
6. Macro Language Functions
- Introduction
- Macro Character Functions
- Macro Evaluation Functions
- Macro Quoting Functions
- Macro Variable Attribute Functions
-
Other Macro Functions
- Using the %SYSFUNC and %QSYSFUNC Macro Functions
- 6.5. Using %SYSFUNC to Format a Date in the TITLE Statement
- 6.6. Using %SYSFUNC to Execute a SAS Language Function and Assign the Result to a Macro Variable
- 6.7. Using %SYSFUNC and the NOTNAME and NVALID SAS Language Functions to Determine If a Value Is a Valid SAS Variable Name
- 6.8. Using %SYSFUNC to Apply a SAS Statistical Function to Macro Variable Values
- 6.9. Using the %SYSFUNC Function to Apply Several SAS Language Functions That Obtain and Display Information about a Data Set
- SAS Supplied Autocall Macro Programs Used Like Functions
-
7. Macro Expressions and Macro Programming Statements
- Introduction
- Macro Language Statements
- Constructing Macro Expressions
- Conditional Processing with the Macro Language
- Iterative Processing with the Macro Language
- Branching in Macro Processing
-
8. Masking Special Characters and Mnemonic Operators
- Introduction
- Why Are Quoting Functions Called Quoting Functions?
- Illustrating the Need for Macro Quoting Functions
- Describing the Commonly Used Macro Quoting Functions
- Understanding How Macro Quoting Functions Work
-
Applying Macro Quoting Functions
- 8.1. Using %STR to Prevent Interpretation of the Semicolon As a SAS Statement Terminator
- 8.2. Using %STR to Prevent Interpretation of the Comma As an Argument Delimiter
- 8.3. Using %STR to Preserve Leading and Trailing Blanks
- 8.4. Using %NRSTR to Mask Macro Triggers
- 8.5. Using %STR and %BQUOTE to Mask Unbalanced Quotation Marks and Preceding Percent Signs
- 8.6. Masking Macro Triggers and Unbalanced Quotation Marks with %NRSTR and Preceding Percent Signs
- 8.7. Using %BQUOTE to Prevent Interpretation of Mnemonic Operators
- 8.8. Using %SUPERQ to Prevent Resolution of Special Characters in a Macro Variable Value
- Specifying Macro Program Parameters That Contain Special Characters or Mnemonic Operators
- Unmasking Text and the %UNQUOTE Function
- Using Quoting Versions of Macro Character Functions and Autocall Macro Programs
-
9. Interfaces to the Macro Facility
- Introduction
-
Understanding DATA Step Interfaces to the Macro Facility
- Understanding the SYMGET and SYMGETN Functions
-
Understanding the SYMPUT and SYMPUTX Call Routines
- 9.4. Saving the Sum of a Variable in a Macro Variable by Executing CALL SYMPUT Once at the End of a DATA Step
- 9.5. Executing CALL SYMPUTX Multiple Times in a DATA Step
- 9.6. Creating Several Macro Variables with CALL SYMPUT and CALL SYMPUTX
- 9.7. Creating a Macro Variable with CALL SYMPUTX and Specifying Its Symbol Table
-
Understanding the CALL EXECUTE Routine
- 9.8. Illustrating the Timing of CALL EXECUTE When It Invokes a Macro Program That Submits Macro Statements
- 9.9. Illustrating the Timing of CALL EXECUTE When It Invokes a Macro Program That Submits Macro Statements and a PROC Step
- 9.10. Using CALL EXECUTE to Conditionally Call a Macro Program
- 9.11. Using CALL EXECUTE to Call a Specific Macro Program
- Understanding the RESOLVE Function
-
Using Macro Facility Features in PROC SQL
-
Creating and Updating Macro Variables with PROC SQL
- 9.14. Using the INTO Clause in PROC SQL to Save Summarizations in Macro Variables
- 9.15. Demonstrating the Default Action of the INTO Clause in Saving the First Row of a Table
- 9.16. Using the INTO Clause in PROC SQL to Create a Macro Variable for Each Row in a Table
- 9.17. Storing All Unique Values of a Table Column in One Macro Variable with PROC SQL
- 9.18. Storing All Values of a PROC SQL Dictionary Table Column in One Macro Variable
- Using the Macro Variables Created by PROC SQL
- Displaying Macro Option Settings with PROC SQL and Dictionary Tables
-
Creating and Updating Macro Variables with PROC SQL
- Using Macro Facility Features in SAS Component Language
-
2. Applying Your Knowledge of Macro Programming
-
10. Storing and Reusing Macro Programs
- Introduction
-
Saving Macro Programs with the Autocall Facility
- Creating an Autocall Library
- Making Autocall Libraries Available to Your Programs
-
Maintaining Access to the Autocall Macro Programs That Ship with SAS
- Defining Filerefs under Windows XP and Using Them to Identify Autocall Libraries
- Explicitly Specifying the Directory Locations of Autocall Libraries on the OPTIONS Statement
- Identifying Autocall Libraries That Are Stored in SAS Catalogs
- Listing the Names of the Autocall Libraries That Are Defined in the SAS Session
- Using the Autocall Facility under Windows, MVS/TSO, and Other Directory-Based Systems
- Saving Macro Programs with the Stored Compiled Macro Facility
- Resolving Macro Program References When Using the Autocall Facility and the Stored Compiled Macro Facility
- 11. Building a Library of Utilities
-
12. Debugging Macro Programming and Adding Error Checking to Macro Programs
- Introduction
- Understanding the Types of Errors That Can Occur in Macro Programming
- Minimizing Errors in Developing SAS Programs That Contain Macro Language
- Categorizing and Checking for Common Problems in Macro Programming
- Understanding the Tools That Can Debug Macro Programming
-
Examples of Solving Errors in Macro Programming
- 12.1. Reviewing System Options When Macro Facility Warnings and Error Messages Are Absent
- 12.2. Attempting to Process a Macro Program When the Macro Processor Does Not Detect a %MEND Statement
- 12.3. Tracing Problems in Expression Evaluation with the %PUT Statement and the MLOGIC System Option
- 12.4. Using %PUT to Trace a Problem at Execution
- 12.5. Finding a Logic Error in the Execution of a Macro Program with the MLOGIC Option
- 12.6. Using the MPRINT Option to Find Errors in SAS Language That Was Generated by Macro Language
- Improving Your Macro Programming by Including Error Checking
-
13. A Stepwise Method for Writing Macro Programs
- Introduction
- Building a Macro Program in Four Steps
-
Applying the Four Steps to an Example
- Step 1: Write, test, and debug the SAS program(s) that you want the macro program to build
- Step 2: Remove hard-coded programming constants from the program(s) in Step 1 and replace these constants with macro variables
- Step 3: Create macro program(s) from the program(s) in Step 2
- Step 4: Refine and generalize the macro program(s) in Step 3 by adding macro language statements like %IF-%THEN and %DO groups
- Executing the REPORT Macro Program
- Enhancing the Macro Program REPORT
-
10. Storing and Reusing Macro Programs
- 3. Appendixes
- Books Available from SAS Press
Product information
- Title: SAS® Macro Programming Made Easy, Second Edition
- Author(s):
- Release date: March 2007
- Publisher(s): SAS Institute
- ISBN: 9781590478820
You might also like
video
How Instagram has evolved using Open Source
Hui Ding explains how open source software has helped lead to Instagram's success—particularly Django, the open …
book
SAS Certified Professional Prep Guide
The official guide by the SAS Global Certification Program, SAS Certified Professional Prep Guide: Advanced Programming …
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition
Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. …
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 3rd Edition
Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. …