Referencing SAS Files

Referencing Permanent SAS Data Sets

To reference a permanent SAS data set in your SAS programs, use a two-level name consisting of the library name and the data set name:
libref.dataset
In the two-level name, libref is the name of the SAS library that contains the data set, and dataset is the name of the SAS data set. A period separates the libref and data set name.
Figure 2.3 Two-Level Permanent SAS Name
Two-Level SAS Name
For example, suppose you want to create a new permanent SAS library named Clinic. In the sample program, Clinic.Admit is the two-level name for the SAS data set Admit, which is stored in the library named Clinic.
data clinic.admit2;
   set clinic.admit;
   weight =round(weight);
run;

Referencing Temporary SAS Files

To reference temporary SAS files, you can specify the default libref Work, a period, and the data set name. For example, the two-level name, Work.Test, references the SAS data set named Test that is stored in the temporary SAS library Work.
Figure 2.4 Two-Level Temporary SAS Library Name
Two-Level Temporary SAS Library Work.Test
Alternatively, you can use a one-level name (the data set name only) to reference a file in a temporary SAS library. When you specify a one-level name, the default libref Work is assumed. For example, the one-level name Test also references the SAS data set named Test that is stored in the temporary SAS library Work.
Figure 2.5 One-Level Temporary SAS Library Name
One-Level Temporary SAS Library Test

Rules for SAS Names

The following rules apply to the names of SAS data sets, variables, and libraries:
  • They must begin with a letter (A-Z, either uppercase or lowercase) or an underscore (_).
  • They can continue with any combination of numbers, letters, or underscores.
  • They can be 1 to 32 characters long.
  • SAS library names (librefs) can be 1 to 8 characters long.
These are examples of valid data set names and variable names:
  • Payroll
  • LABDATA1995_1997
  • _EstimatedTaxPayments3
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.32