SAS Data Sets


Many SAS/GRAPH procedures use SAS data sets as input or output. When a SAS/GRAPH procedure requires an input SAS data set, you usually specify the data set with the DATA= option in the procedure statement, as shown in this example:

 proc gplot data=reflib.stocks; 

If you omit the DATA= option, the procedure uses the value of the SAS system option _LAST_=. The default for _LAST_= is the most recently created SAS data set (either permanent or temporary) in the current SAS job or session.

If you do not specify a 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 set specification, as shown in this example:

 proc gplot data=reflib.stocks(where=(year=1997)); 

For more information on SAS data sets and other data processing details, see SAS Language Reference: Concepts . For a complete discussion of SAS data set options and SAS system options, see SAS Language Reference: Dictionary .

Temporary and Permanent SAS Data Sets

SAS data sets are stored in SAS libraries and can be temporary or permanent. You can specify a data set in either of two methods : using a library reference, or using a file specification. A library reference is specified without quotation marks in the form libref.SAS-data-set- name . A file specification must be enclosed in single quotation marks and uses the file naming conventions of your operating environment.

Using a Library Reference to Specify a Data Set

Typically, temporary SAS data sets are stored in the WORK data library and are referenced with a one-level name. The WORK library is defined automatically at the beginning of the SAS session and is automatically deleted at the end of the SAS session. Procedures assume that SAS data sets that are specified with a one-level name are to be read from, or written to, the WORK data library, unless you specify a USER data library. For example, this statement specifies a temporary data set from the WORK library:

 proc gplot data=stocks; 

Typically, permanent SAS data sets have a two-level name of 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 also LIBNAME Statement on page 29. For example, these statements specify a permanent data set:

 libname reflib '  my-SAS-library  ';  proc gplot data=reflib.stocks; 

You can use a one-level name for permanent SAS data sets if you specify a USER data library. In this case, the procedure assumes that data sets with one-level names are in the USER data library instead of in the WORK data library. You can assign a USER data library with a LIBNAME statement or the USER= SAS system option. For example, these 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; 

Using a File Specification to Specify a Data Set

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

  • SAS catalog names

  • MDDB and FDB references

  • PROC SQL

  • the _LAST_= system option.

Data Set Requirements

SAS/GRAPH procedures often have certain requirements for the input data sets they use. Some procedures may expect the input data set to be sorted in a certain way while others may 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 specific requirements, see "About the Input Data Set" in the "Concepts" section of the procedure chapter.

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 may end with errors.




SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net