backnextLearning Path
   


Introduction

Like macro variables, macro programs (also known as macros) enable you to substitute text into your SAS programs. Macros are different from macro variables because they can use conditional logic to make decisions about the text that you substitute into your programs. Using macros can help make your SAS programs more dynamic and reusable.

For example, suppose you submit a SAS program every day to create registration listings for courses that are to be held later in the current month. Then, suppose that every Friday you also submit a SAS program to create a summary of revenue that has been generated so far in the current month. By using a macro, you can automate the process so that only one SAS program is required. This program will always submit the daily report and will conditionally submit the weekly report if it is Friday. Furthermore, you could create and store a macro that would automate this process, and the only code you would need to submit each day is this:

    %reports

Time to Complete

This lesson contains pages and takes approximately 2 hours to complete.



Objectives

In this lesson, you learn to

  • define and call simple macros
  • describe the basic actions that the macro processor performs during macro compilation and execution
  • use system options for macro debugging
  • interpret error messages and warning messages that the macro processor generates
  • define and call macros that include parameters
  • describe the difference between positional parameters and keyword parameters
  • explain the difference between the global symbol table and local symbol tables
  • describe how the macro processor determines which symbol table to use
  • describe the concept of nested macros and the hierarchy of symbol tables
  • conditionally process code within a macro program
  • iteratively process code within a macro program.

Prerequisites

Before taking this lesson, you should complete the following lessons:

  • .

  Copyright © 2003 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement
backnext