Data Set Names

Data Set Names

Where to Use Data Set Names

You can use SAS data sets as input for DATA or PROC steps by specifying the name of the data set in

  • a SET statement

  • a MERGE statement

  • an UPDATE statement

  • a MODIFY statement

  • the DATA= option of a SAS procedure

  • the OPEN function.

How and When SAS Data Set Names Are Assigned

You name SAS data sets when you create them. Output data sets that you create in a DATA step are named in the DATA statement. SAS data sets that you create in a procedure step are usually given a name in the procedure statement or an OUTPUT statement. If you do not specify a name for an output data set, SAS assigns a default name.

If you are creating SAS data views, you assign the data set name using one of the following:

  • the SQL procedure

  • the ACCESS procedure

  • the VIEW= option in the DATA statement.

Note: Because you can specify both SAS data files and SAS data views in the same program statements but cannot specify the member type, SAS cannot determine from the program statement which one you want to process. This is why SAS prevents you from giving the same name to SAS data views and SAS data sets in the same library.

Parts of a Data Set Name

The complete name of every SAS data set has three elements. You assign the first two; SAS supplies the third. The form for SAS data set names is as follows :


The elements of a SAS data set name include the following:


  • is the logical name that is associated with the physical location of the SAS data library.


  • is the data set name, which can be up to 32 bytes long for the Base SAS engine starting in Version 7. Earlier SAS versions are limited to 8-byte names.


  • is assigned by SAS. The member type is DATA for SAS data files and VIEW for SAS data views.

When you refer to SAS data sets in your program statements, use a one- or two-level name. You can use a one-level name when the data set is in the temporary library WORK. In addition, if the reserved libref USER is assigned, you can use a one-level name when the data set is in the permanent library USER. Use a two-level name when the data set is in some other permanent library you have established. A two-level name consists of both the libref and the data set name. A one-level name consists of just the data set name.

Two-level SAS Data Set Names

The form most commonly used to create, read, or write to SAS data sets in permanent SAS data libraries is the two-level name as shown here:


When you create a new SAS data set, the libref indicates where it is to be stored. When you reference an existing data set, the libref tells SAS where to find it. The following examples show the use of two-level names in SAS statements:

 data revenue.sales;  proc sort data=revenue.sales; 

One-level SAS Data Set Names

You can omit the libref, and refer to data sets with a one-level name in the following form:


Data sets with one-level names are automatically assigned to one of two SAS libraries: WORK or USER. Most commonly, they are assigned to the temporary library WORK and are deleted at the end of a SAS job or session. If you have associated the libref USER with a SAS data library or used the USER= system option to set the USER library, data sets with one-level names are stored in that library. See Chapter 26, 'SAS Data Libraries,' on page 467 for more information on using the USER and WORK libraries. The following examples show how one-level names are used in SAS statements:

 data 'test3';  set 'stratifiedsample1'; 

SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255 © 2008-2017.
If you may any questions please contact us: