SAS Macro Programming Made Easy, 2/e

Michele Burlew

  • 出版商: SAS Press
  • 出版日期: 2007-03-30
  • 售價: $2,040
  • 貴賓價: 9.5$1,938
  • 語言: 英文
  • 頁數: 448
  • 裝訂: Paperback
  • ISBN: 1590478827
  • ISBN-13: 9781590478820
  • 已絕版

買這商品的人也買了...

商品描述

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

Preface   ix
Acknowledgments   xi

 

Part 1    Understanding the Concepts and Features of
              Macro Programming   1

Chapter 1     Introduction   3

What Is the SAS Macro Facility?   4

What Are the Advantages of the SAS Macro Facility?   6

Where Can the SAS Macro Facility Be Used?   12

Examples of the SAS Macro Facility   13

Chapter 2     Mechanics of Macro Processing   23

Introduction   23

The Vocabulary of SAS Processing   24

SAS Processing without Macro Activity   25

Understanding Tokens   26

Tokenizing a SAS Program   28

Comparing Macro Language Processing and SAS Language
Processing   29

Processing a SAS Program That Contains Macro Language   30

Chapter 3     Macro Variables   39

Introduction   40

Basic Concepts of Macro Variables   40

Referencing Macro Variables   42

Understanding Macro Variable Resolution and the Use of Single and Double Quotation Marks   44

Displaying Macro Variable Values   46

Understanding Automatic Macro Variables   52

Understanding User-Defined Macro Variables   56

Combining Macro Variables with Text   59

Referencing Macro Variables Indirectly   65

Chapter 4     Macro Programs   73

Introduction   74

Creating Macro Programs   74

Executing a Macro Program   78

Displaying Notes about Macro Program Compilation in the
SAS Log   80

Displaying Messages about Macro Program Processing in the
SAS Log   82

Passing Values to a Macro Program through Macro Parameters   85

Chapter 5     Understanding Macro Symbol Tables and the
                     Processing of Macro Programs   101

Introduction   102

Understanding Macro Symbol Tables   102

Processing of Macro Programs   122

Chapter 6     Macro Language Functions   133

Introduction   133

Macro Character Functions   134

Macro Evaluation Functions   138

Macro Quoting Functions   140

Macro Variable Attribute Functions  143

Other Macro Functions   147

SAS Supplied Autocall Macro Programs Used Like Functions   154

Chapter 7     Macro Expressions and Macro Programming
                      Statements   159

Introduction   160

Macro Language Statements   160

Constructing Macro Expressions   163


Conditional Processing with the Macro Language   167

Iterative Processing with the Macro Language   177

Branching in Macro Processing   184

Chapter 8     Masking Special Characters and Mnemonic
            
         Operators   189

Introduction   190

Why Are Quoting Functions Called Quoting Functions?   191

Illustrating the Need for Macro Quoting Functions   191

Describing the Commonly Used Macro Quoting Functions   192

Understanding How Macro Quoting Functions Work   194

Applying Macro Quoting Functions   195

Specifying Macro Program Parameters That Contain Special Characters or Mnemonic Operators   203

Unmasking Text and the %UNQUOTE Function   213

Using Quoting Versions of Macro Character Functions and Autocall Macro Programs   214

Chapter 9     Interfaces to the Macro Facility   217

Introduction   218

Understanding DATA Step Interfaces to the Macro Facility   218

Using Macro Facility Features in PROC SQL   251

Using Macro Facility Features in SAS Component Language   262

 

Part 2    Applying Your Knowledge of Macro
              Programming   267

Chapter 10   Storing and Reusing Macro Programs   269

Introduction   270

Saving Macro Programs with the Autocall Facility   270

Saving Macro Programs with the Stored Compiled Macro
Facility   278

Resolving Macro Program References When Using the Autocall Facility and the Stored Compiled Macro Facility   283

 


Chapter 11   Building a Library of Utilities   285

Introduction   285

Writing a Macro Program to Behave Like a Function   286

Programming Routine Tasks   290

Chapter 12   Debugging Macro Programming and Adding Error
                     Checking to Macro Programs   297

Introduction   298

Understanding the Types of Errors That Can Occur in Macro
Programming   298

Minimizing Errors in Developing SAS Programs That Contain Macro Language   299

Categorizing and Checking for Common Problems in Macro
Programming   299

Understanding the Tools That Can Debug Macro Programming   303

Examples of Solving Errors in Macro Programming   307

Improving Your Macro Programming by Including Error
Checking   326

Chapter 13   A Stepwise Method for Writing Macro Programs   335

Introduction   336

Building a Macro Program in Four Steps   336

Applying the Four Steps to an Example   337

 

Part 3    Appendixes   369

Appendix A  Abridged Macro Language Reference   371

Selected SAS Options Used with the Macro Facility   372

Automatic Macro Variables   373

Macro Functions   377

Macro Language Statements   381

PROC SQL Interface to the Macro Facility   386

SAS Functions and Routines That Interface with the Macro
Facility   387

 


Appendix B  Reserved Words in the Macro Facility   391

Appendix C  Sample Data Set   393

Appendix D  Reference to Programs in This Book   399

Index   407