Previous Page | Next Page

SAS System Options

VALIDVARNAME= System Option



Specifies the rules for valid SAS variable names that can be created and processed during a SAS session.
Default: V7
Valid in: configuration file, SAS invocation, OPTIONS statement, SAS System Options window
Category: Files: SAS Files
PROC OPTIONS GROUP= SASFILES

Syntax
Syntax Description
See Also

Syntax

VALIDVARNAME=V7 | UPCASE | ANY


Syntax Description

V7

specifies that variable names must follow these rules:

  • can be up to 32 characters in length.

  • must begin with a letter of the Latin alphabet (A - Z, a - z) or the underscore character. Subsequent characters can be letters of the Latin alphabet, numerals, or underscores.

  • cannot contain blanks.

  • cannot contain special characters except for the underscore.

  • 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. You cannot, therefore, 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.

  • cannot be assigned the names of special SAS automatic variables (such as _N_ and _ERROR_) or variable list names (such as _NUMERIC_, _CHARACTER_, and _ALL_).

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:

  • can be up to 32 characters in length

  • can be special and multi-byte characters not to exceed 32 bytes.

  • cannot contain any null bytes

  • leading blanks are preserved, but trailing blanks are ignored

  • name must contain at least one character. An all blank name is not permitted.

  • can begin with or contain any characters, including blanks

    Note:   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. See SAS Name Literals and Avoiding Errors When Using Name Literals in SAS Language Reference: Concepts.

    If you use 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.  [cautionend]

  • 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. You cannot, therefore, 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.

Warning: The intent of the VALIDVARNAME=ANY option is to enable compatibility with other DBMS variable (column) naming conventions, such as allowing embedded blanks and national characters. Throughout SAS, using the name literal syntax with variable names that exceed the 32-byte limit or have excessive embedded quotation marks might cause unexpected results.

See Also

"Rules for Words and Names in the SAS Language" in SAS Language Reference: Concepts

Previous Page | Next Page | Top of Page