Chapter 4: Scope

Scope

The Program Data Vector (PDV)

KEEP and DROP

Scope in Other Programming Blocks

Scope

In programming, scope is the area in which a variable is visible. In other words, scope lets you know where a variable can be accessed. If you write SAS macro functions, you are familiar with local (%local) and global (%global) macro variables. Suppose you have the following code:

%local macVar

The variable is available only in the macro. When the macro completes, the variable is no longer available. Suppose you have the following code:

%global macVar;

This variable is available to all procedures, macros (including macro variables or functions), and DATA steps during the entire SAS session. What sometimes confuses a SAS programmer learning ...

Get The DS2 Procedure: SAS Programming Methods at Work now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.