SAS Macro Programming

SAS Macro Programming Courseware (SASMACPRO)

The SAS Macro Programming course is intended for intermediate or experienced SAS users in programming roles. This course covers writing macro programs, techniques and tips. Learn to write SAS macro programs fast and efficiently.

This course use data from the SASHELP library installed with the software. These courses can be taught

  • using SAS Version 9 or higher
  • any operating system (focus is either Windows or Linux/Unix. If using MVS you may need to modify as necessary)
  • any interface (SAS Enterprise Guide is the focus. If using SAS Studio or SAS Display Manager you may need to modify slightly as necessary)
  • your installation of SAS, or SAS On Demand for Academics (free version of SAS for learning purposes)

Benefits

At the end of this course students will be able to:

  • Create and use SAS macro variables
  • Write SAS Macro programs
  • Debug SAS Macro programs
  • Differentiate between the different symbol tables
  • Work with compiled SAS Macro

Outline

  • Introduction
    • Review common functionality from SAS Programming Essentials course.
    • Describe the two components of the SAS Macro Facility.
    • List the three tips to making your SAS macro code easier to debug.
  • Macro Processing Mechanics
    • List the different types of tokens.
    • Describe how a SAS program is processed.
    • List the macro triggers.
    • Describe how a SAS program is processed with macro triggers.
  • Macro Variables
    • List the two different types of macro variables.
    • Display the automatic macro variables.
    • Use an automatic macro variable.
    • Create a user-defined macro variable with a %LET statement.
    • Use a user-defined macro variable.
  • Macro Programs
    • Describe the purpose of a macro program.
    • Differentiate between compile and execution of a macro program.
    • Create a macro definition.
    • Call a macro.
    • Debug with MPRINT and MLOGIC options.
    • Make a macro more dynamic with parameters.
  • Macro Symbol Tables, Compilation, and Execution
    • Describe where macro variables are stored.
    • Differentiate between the Global and Local symbol tables.
    • Describe where macro programs are stored.
  • Storing and Reusing Macros
    • Store compiled Macro programs in a permanent SAS library.
    • Store uncompiled Macro programs and make them always accessible to your program.
  • Macro Language Functions
    • Use macro character functions.
    • Use macro evaluation functions.
    • Call a SAS supplied autocall macro.
    • Mimic a SAS function using %SYSFUNC.
  • Macro Flow Control Statements
    • Conditionally submit code to the SAS compiler.
    • Repetitively submit code to the SAS compiler.
  • Interfaces to the Macro Facility
    • Create macro variables from data using CALL SYMPUTX.
    • Create macro variables from data using PROC SQL.
  • Indirect References to Macro Variables
    • Use multiple ampersands for indirect references to macro variables.
  • Masking Special Characters
    • Describe why you would need macro quoting functions.
    • Use macro quoting functions.

Required Prerequisites

Before attending this course, you need to be able to do the following:

  • Write simple SQL queries using the SELECT statement.
  • Read from and write to SAS tables using a DATA step.
  • Use DATA step programming statements, including IF-THEN/ELSE, DO WHILE, DO UNTIL, and iterative DO.
  • Use character functions such as SUBSTR.
  • Filter data using the WHERE statement.
  • Use SAS procedures such as SORT and PRINT.

Useful Prerequisites

Before attending this course, it is useful to know the following:

  • Use summary functions in SQL.
  • Describe the compilation and execution phases of the DATA step.
  • Describe the Program Data Vector (PDV).
  • Use character functions such as SCAN, UPCASE, and LOWCASE.
License

Length: 2 days | $125.00 per copy

LicenseRequest More InformationDownload Sample CopyRequest Trainer Evaluation Copy
What is Included?
  • Student Manual
  • Student Class Files
  • PowerPoint Presentation