VALIDVARNAME= System Option
Specifies the rules for valid SAS variable names
that can be created and processed during a SAS session.
Valid in: |
Configuration file, SAS invocation, OPTIONS statement, SAS
System Options window
|
Category: |
Files: SAS Files |
PROC OPTIONS GROUP= |
SASFILES |
Default: |
V7 |
Note: |
This option can be restricted by a site administrator. For more information,
see Restricted Options. |
Syntax
Syntax Description
- V7
-
specifies that variable
names must follow these rules:
-
The length of a SAS variable names
can be up to 32 characters.
-
The first character must begin
with a letter of the Latin alphabet (A - Z, a - z) or the underscore.
Subsequent characters can be letters of the Latin alphabet, numerals,
or underscores.
-
Trailing blanks are ignored. The
variable name alignment is left justified.
-
A variable name cannot contain
blanks or special characters except for the underscore.
-
A variable name can contain mixed-case
letters. SAS stores and writes the variable name in the same case
that is used in the first reference to the variable. However, when
SAS processes a variable name, SAS internally converts it to uppercase.
Therefore, you cannot use the same variable name with a different
combination of uppercase and lowercase letters to represent different
variables. For example,
cat
,
Cat
,
and
CAT
all represent the same variable.
-
Do not assign variables the names
of special SAS automatic variables (such as _N_ and _ERROR_) or variable
list names (such as _NUMERIC_, _CHARACTER_, and _ALL_) to variables.
Examples:season=’summer’;
percent_of_profit=percent;
- UPCASE
-
specifies that the
variable name follows the same rules as V7, except that the variable
name is uppercase, as in earlier versions of SAS.
- ANY
-
specifies that SAS
variable names must follow these rules:
-
The name can begin with or contain
any characters, including blanks, national characters, special characters,
and multi-byte characters.
-
The name can be up to 32 bytes
in length
-
The name cannot contain any null
bytes
-
Leading blanks are preserved, but
trailing blanks are ignored
-
The name must contain at least
one character. A name with all blanks is not permitted.
-
The name contain mixed-case letters.
SAS stores and writes the variable name in the same case that is used
in the first reference to the variable. However, when SAS processes
a variable name, SAS internally converts it to uppercase. Therefore,
you cannot use the same variable name with a different combination
of uppercase and lowercase letters to represent different variables.
For example,
cat
,
Cat
,
and
CAT
all represent the same variable.
Requirement:If you use any characters other than the ones that are
valid when the VALIDVARNAME system option is set to V7 (letters of
the Latin alphabet, numerals, or underscores), then you must express
the variable name as a name literal and you must set VALIDVARNAME=ANY.
If the name includes either the percent sign (%) or the ampersand
(&), then you must use single quotation marks in the name literal
in order to avoid interaction with the SAS Macro Facility. See
SAS Name Literals in SAS Language Reference: Concepts and Avoiding Errors When Using Name Literals in SAS Language Reference: Concepts.
Examples:‘% of profit’n=percent;
‘items@warehouse’n=itemnum;
CAUTION:
Throughout
SAS, using the name literal syntax with SAS member names that exceed
the 32-byte limit or have excessive embedded quotation marks might
cause unexpected results.
The intent of the VALIDVARNAME=ANY
system option is to enable compatibility with other DBMS variable
(column) naming conventions, such as allowing embedded blanks and
national characters.