SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Improving Program Efficiency with Macro Variables
Lesson Overview


Introduction

SAS macro variables enable you to substitute text in your SAS programs. Macro variables can supply a variety of information, from operating system information to SAS session information to any text string you define. By substituting text into programs, SAS macro variables make your programs easy to update, as this program shows:

     %let year=1999;
     title "Temporary Employees for &year";
     data hrd.newtemp;
        set hrd.temp;
        if year(enddate)=&year;
     run;
     proc print data=hrd.newtemp;
     run;

This lesson teaches you how to use the automatic macro variables supplied by the SAS System and to create and reference your own macro variables.

This lesson contains 48 pages and takes approximately 60-90 minutes to complete.


Objectives

After completing this lesson, you will be able to

  • create macro variables with the %LET statement
  • create macro variables with the CALL SYMPUT routine
  • reference automatic and user-defined macro variables
  • identify when macro variable references are resolved
  • display log messages stating how macro variable references resolve when using the SYMBOLGEN option
  • combine macro variable references with prefixes and suffixes.


Prerequisites

Before taking this lesson, you should have completed the following lessons:

Introduction to SAS Programming

Creating SAS Data Sets

Creating and Modifying Variables


  ||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement