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.
The names of these SAS language elements can be up to 32 characters in length:
  • members of SAS libraries, including SAS data sets, data views, catalogs, catalog entries, and indexes
  • variables in a SAS data set
  • macros and macro variables
These SAS language elements have a maximum length of eight characters:
  • librefs and filerefs
  • SAS engine names
  • names of SAS/ACCESS access descriptors and view descriptors
  • variable names in SAS/ACCESS access descriptors and view descriptors
For a complete description of SAS naming conventions, see the SAS Language Reference: Concepts.

Case Sensitivity

When SAS encounters mixed-case or case-sensitive names in SAS code, SAS stores and displays the names as they are specified. If the SAS variables, Flight and dates, are defined in mixed case—for example:
input Flight $3. +3 dates date9.;
Then SAS displays the variable names as defined. The column headings appear as defined.
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 defined, 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, followed by the letter n. Name literals enable you to 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.
  • You can use a name literal only for SAS variable and data set names, statement labels, and DBMS column and table names.
  • You can use name literals only in a DATA step or in the SQL procedure.
  • If a name literal contains any characters that are not allowed when VALIDVARNAME=V7, you must set the system option to VALIDVARNAME=ANY. For more information, see VALIDVARNAME=.