SAS 9.1 Macro Language Reference
Original Publication Date: 2004-Dec-31
Included in the Prior Art Database: 2015-Sep-17
SAS Institute Inc.
Page 01 of 348
SAS® 9.1 Macro Language
Page 02 of 348
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2004. SAS ® 9.1 Macro Language: Reference. Cary, NC: SAS Institute Inc.
SAS® 9.1 Macro Language: Reference
Copyright © 2004, SAS Institute Inc., Cary, NC, USA
All rights reserved. Produced in the United States of America. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc.
U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of this software and related documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.227-19 Commercial Computer Software-Restricted Rights (June 1987).
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
1st printing, January 2004
SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228.
SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.
Page 03 of 348
P A R T 1 Understanding and Using the Macro Facility 1
Chapter 1 Introduction to the Macro Facility 3
Getting Started with the Macro Facility 3
Replacing Text Strings Using Macro Variables 4 Generating SAS Code Using Macros 5
More Advanced Macro Techniques 8
Other Features of the Macro Language 10
Chapter 2 SAS Programs and Macro Processing 11
Introduction to SAS Programs and Macro Processing 11
How SAS Processes Statements without Macro Activity 12
How SAS Processes Statements with Macro Activity 14
Chapter 3 Macro Variables 19
Introduction to Macro Variables 19
Macro Variables Defined by SAS 20
Macro Variables Defined by Users 22
Using Macro Variables 25
Displaying Macro Variable Values 28
Referencing Macro Variables Indirectly 29
Manipulating Macro Variable Values with Macro Functions 30
Chapter 4 Macro Processing 33
Introduction to Macro Processing 33
Defining and Calling Macros 33
How the Macro Processor Compiles a Macro Definition 34
How the Macro Processor Executes a Compiled Macro 36
Summary of Macro Processing 40
Chapter 5 Scopes of Macro Variables 41
Introduction to the Scopes of Macro Variables 41
Global Macro Variables 42
Local Macro Variables 43
What's New vii
New Automatic Macro Variable vii
New Comparison Operators vii
New SAS System Options viii
New Macro Statements viii
New Macro Functions viii