Names in the SAS Language
Definition of a SAS Name
A SAS name is a name token that represents one of the following SAS language
elements:
variable
data set
format
informat
procedure
option
statement label
libref or fileref
catalog entry
array
macro or macro variable
component object
There are two types of names in SAS:
SAS language element names (system-supplied names)
user-supplied names
The following sections will discuss user-supplied SAS names.
Rules for User-Supplied SAS Names
Rules for Most SAS Names
The following list contains the rules that you use when you create most SAS names:
Note: The rules are more flexible for SAS variable names, data set names, view names,
and item store names than for other language elements. See “Rules for SAS Variable
Names” on page 26 and “Rules for SAS Data Set Names, View Names, and Item
Store Names” on page 27.
The length of a SAS name depends on which element it is assigned to. Many SAS
names can be 32 bytes long; others have a maximum length of 8 bytes. For a list of
SAS names and their maximum length, see Table 3.1 on page 25.
The first character must be an English letter (A, B, C, . . ., Z) or underscore (_).
Subsequent characters can be letters, numeric digits (0, 1, . . ., 9), or underscores.
You can use uppercase or lowercase letters.
Blanks cannot appear in SAS names.
Special characters, except for the underscore, are not allowed. In filerefs only, you
can use the dollar sign ($), the number sign (#), and the at sign (@).
SAS reserves a few names for automatic variables and variable lists, SAS data sets,
and librefs.
When creating variables, do not use the names of special SAS automatic
variables (for example, _N_ and _ERROR_) or special variable list names (for
example, _CHARACTER_, _NUMERIC_, and _ALL_).
When associating a libref with a SAS library, do not use these libref names:
Sashelp
24 Chapter 3 Rules for Words and Names in the SAS Language
Sasmsg
Sasuser
Work
When you create SAS data sets, do not use these names:
_NULL_
_DATA_
_LAST_
When assigning a fileref to an external file, do not use the filename SASCAT.
When you create a macro variable, do not use names that begin with SYS.
Table 3.1 Maximum Length in Bytes of User-Supplied SAS Names
User-Supplied SAS Name Maximum Length in Bytes
Arrays 32
CALL routines 16
Catalog entries 32
Component objects 32
DATA step statement labels 32
DATA step variable labels 256
DATA step variables 32
DATA step windows 32
Engines 8
Filerefs 8
Formats, character 31
Formats, numeric 32
Functions 16
Generation data sets 28
Informats, character 30
Informats, numeric 31
Librefs 8
Macro variables 32
Names in the SAS Language 25

Get SAS 9.4 Language Reference, 6th Edition 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.