Specifying an Input Data Set

How to Specify an Input Data Set

You can specify an input data set by using one of the following methods:
  • a library reference
  • a file specification
When using either of these methods, you usually specify the DATA= option in the procedure statement, as shown in this example:
proc gplot data=stocks;
If you omit the DATA= option, then the procedure uses the SAS data set that was most recently used or created in the current SAS session.
If you do not specify a SAS data set and no data set has been created in the current SAS session, an error occurs and the procedure stops.
Most of the procedures that read data sets or create output data sets accept data set options. SAS data set options appear in parentheses after the DATA= option specification, as shown in this example:
proc gplot data=stocks(where=(year=1997));

Using a Library Reference

A SAS library is a storage location for SAS data sets in your operating environment. Data sets stored in a SAS Library are created and referenced using either a one- or two-level name. SAS data sets stored in the temporary WORK library are usually specified using a one-level name. Procedures assume that SAS data sets that are specified with a one-level name are to be read from or written to the WORK library. Since temporary SAS data sets are typically stored by default in the WORK data library, you can specify them using a one-level name and SAS knows where to find them. For example, this statement specifies the data set stocks that resides in the WORK library:
proc gplot data=stocks;
To specify a permanent data set you typically use a two-level name. A permanent library reference is specified in the form libref.SAS-data-set-name in which libref identifies a storage location on your host system. A LIBNAME statement associates a libref with the storage location. See details in the LIBNAME Statement in SAS Statements: Reference. For example, the following statements specify a permanent data set:
 libname  reflib 'my-SAS-library';
      proc gplot data=reflib.stocks;
 run;
You can use a one-level name for permanent SAS data sets if you specify a USER library. In this case, the procedure assumes that data sets with one-level names are in the USER library instead of in the WORK library. You can assign a USER library with a LIBNAME statement or the USER= SAS system option. For example, the following statements use a single-level name to specify a permanent data set that is stored in the library identified as the USER library:
options user='my-SAS-library';
proc gplot data=stocks;
For more information, see SAS Libraries in SAS Language Reference: Concepts.

Using a File Specification

To use a file specification for specifying a data set, enclose the file specification in single quotation marks. The specification can be a filename, or a path and filename. The specification must follow the file naming conventions of your operating environment.
For example, the following code creates a file named mydata in the default storage location, which is the location where the SAS session was started:
data 'mydata';
The quotes are required for a file specification; if omitted, SAS treats the specification as a library reference. In the above example, if the quotes are omitted, SAS creates the data set in the temporary WORK catalog and identifies it by the name WORK.MYDATA.
To create the file in a location other than the default location, the quoted file specification must include the full path to the desired location.
You cannot use quoted file specifications for the following items:
  • SAS catalog names
  • MDDB and FDB references
  • the _LAST_= system option

Input Data Set Requirements

SAS/GRAPH procedures often have certain requirements for the input data sets they use. Some procedures might require the input data set to be sorted in a certain way while others might require the data set to contain certain variables or types of information. If necessary, you can use DATA steps and Base SAS procedures in your program to manipulate the data appropriately. For more information about the requirements of any given procedure, see the “Concepts” section, which is included at the beginning of each procedure overview.

Automatic Data Set Locking

All SAS/GRAPH procedures that produce graphics output automatically lock the input data sets during processing. By locking a data set, SAS/GRAPH software prevents another user from updating the data at the same time you are using it to produce a graph. If data in a data set changes while you are using it to draw a graph, unpredictable results can occur in the graph or your program can end with errors.