SAS Naming Conventions

Length of Name

SAS naming conventions allow long names for SAS data sets and SAS variables. For example, MYDB.TEMP_EMPLOYEES_QTR4_2000 is a valid two-level SAS name for a data set.

Some SAS names can be up to 32 characters, depending on the SAS session encoding and the limits of the object name length of the DBMS. These SAS names can be up to 32 characters:

These SAS language elements have a maximum length of eight characters:

For a description of SAS naming conventions, see Rules for Most SAS Names in SAS Programmer’s Guide: Essentials.

Case Sensitivity

When SAS encounters mixed-case or case-sensitive names in SAS code, SAS stores and displays the names as they are specified. In the following example, two SAS variables (Flight and dates) are specified in mixed case.

input Flight $3. +3 dates date9.;

SAS then displays the variable names as specified, and the column headings appear as specified.

Mixed-Case Names Displayed in Output

           SAS System

    Obs    Flight        dates

     1      114      01MAR2000
     2      202      01MAR2000
     3      204      01MAR2000 

Although SAS stores variable names as they are specified, it recognizes variables for processing without regard to case. For example, SAS processes these variables as FLIGHT and DATES. Likewise, renaming the Flight variable to "flight" or "FLIGHT" would result in the same processing.

SAS Name Literals

A SAS name literal is a name token that is expressed as a quoted string that is followed by the letter n. By using name literals, you can use special characters or blanks that are not otherwise allowed in SAS names when you specify a SAS data set or variable. Name literals are especially useful for expressing database column and tables names that contain special characters.

Here are two examples of name literals.

data mydblib.'My Staff Table'n;

data Budget_for_1999;
 input '$ Amount Budgeted'n 'Amount Spent'n; 

Name literals are subject to certain restrictions.

Last updated: February 3, 2026