Chapter Contents

Previous

Next

Data Set Names


Where to Use

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


How and When 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:

If you are using an interface library engine to access the data, the rules for assigning data set names vary according to the engine.

Note:   Because you can specify them both as data sets 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  [cautionend]


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:

libref.member-name.membertype

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

libref
is the logical name of a SAS data library.

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

membertype
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-level or two-level name. Use a one-level name when the data set is in a temporary library, such as USER or WORK. 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 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:

libref.data-set-name

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 program statements:

data revenue.sales;

proc sort data=revenue.sales;


One-level Names

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

data set-name

Data sets with one-level names are automatically assigned to one of two special SAS libraries: WORK or USER. Most commonly, they are assigned to the temporary library WORK and they 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 SAS Data Libraries for more information on using the USER and WORK libraries. The following examples show how one-level names are used in SAS program statements:

data 'test3';

set 'stratifiedsample1';


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.