Although the macro facility does not exist within CAS, there are several macro variables
in the client to help write the code that will run in CAS. For more information, see SAS
Cloud Analytic Services: Language Reference and SAS Cloud Analytic Services:
Accessing and Manipulating Data.
Replacing Text Strings Using Macro Variables
Macro variables are an efficient way of replacing text strings in SAS code. The simplest
way to define a macro variable is to use the %LET statement to assign the macro
variable a name (subject to standard SAS naming conventions), and a value.
%let city=New Orleans;
Now you can use the macro variable CITY in SAS statements where you would like the
text New Orleans to appear. You refer to the variable by preceding the variable name
with an ampersand (&), as in the following TITLE statement:
title "Data for &city";
The macro processor resolves the reference to the macro variable CITY:
title "Data for New Orleans";
A macro variable can be defined within a macro definition or within a statement that is
outside a macro definition (called open code).
Note: The title is enclosed in double quotation marks. In quoted strings in open code,
the macro processor resolves macro variable references within double quotation
marks but not within single quotation marks.
A %LET statement in open code (outside a macro definition) creates a global macro
variable that is available for use anywhere (except in DATALINES or CARDS
statements) in your SAS code during the SAS session in which the variable was created.
There are also local macro variables, which are available for use only inside the macro
definition where they are created. For more information about global and local macro
variables, see Scope of Macro Variables on page 49.
Macro variables are not subject to the same length limits as SAS data set variables. The
value that you want to assign to a macro variable can contain certain special characters
(for example, semicolons, quotation marks, ampersands, and percent signs) or
mnemonics (for example, AND, OR, or LT). You must use a macro quoting function to
mask the special characters. Otherwise, the special character or mnemonic might be
misinterpreted by the macro processor. For more information, see Macro Quoting on
page 82.
Macro variables are useful for simple text substitution. They cannot perform conditional
operations, DO loops, and other more complex tasks. For this type of work, you must
define a macro.
8 Chapter 1 Introduction to the Macro Facility
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset