SAS provides a number of features and procedures for reading from and writing to files that are stored on sequential format devices, either disk or tape. Before you store SAS data libraries in sequential format, you should consider the following:
You cannot use random access
You can access only one of the SAS files in a sequential library, or only one of the SAS files on a tape, at any point in a SAS job.
For example, you cannot read two or more SAS data sets in the same library or on the same tape at the same time in a single DATA step. However, you can access
two or more SAS files in different sequential libraries, or on different tapes at the same time, if there are enough tape
a SAS file during one DATA or PROC step, then access another SAS file in the same sequential library or on the same tape during a later DATA or PROC step.
Also, when you have more than one SAS data set on a tape or in a sequential library in the same DATA or PROC step, one SAS data set file may be opened during the compilation phase, and the additional SAS data sets are opened during the execution phase. For more information, see the SET statement
For some operating environments, you can only read from or write to SAS data sets during a DATA or PROC step. However, you can always use the COPY procedure to transfer all
Considerations specific to your site can affect your use of tape. For example, it may be necessary to manually mount a tape before the SAS data libraries become available. Consult your operations staff if you are not familiar with using tape storage at your location.
For information on sequential engines, see Chapter 37, "SAS Engines," on page 601.
Operating Environment Information: The details for storing and accessing SAS files in sequential format vary with the operating environment. See the SAS documentation for your operating environment for more information.
The SAS utilities that are available for SAS file management enable you to work with more than one SAS file at a time, as long as the files belong to the same library. The advantage of learning and using SAS Explorer, functions, options, and procedures is that they automatically copy, rename, or delete any index files or integrity constraints, audit trails,
There are several SAS window options, functions, and procedures available for performing file management
CATALOG procedure
provides catalog management utilities with the COPY, CONTENTS, and APPEND procedures.
DATASETS procedure
provides all library management functions for all member types except catalogs. If your site does not use the SAS Explorer, or if SAS executes in batch or interactive line mode, using this procedure can save you time and resources.
SAS Explorer
includes
DETAILS system option
Sets the default display for file information when using the CONTENTS, or DATASETS procedure. When enabled, DETAILS provides additional information about files, depending on which procedure or window you use.
SAS Explorer and SAS procedures enable you to obtain a list, or
directory
, of the
| Note |
SAS data libraries can also contain various SAS utility files. These files are not listed in the library directory and are for internal processing. |
SAS provides another method of accessing files in addition to assigning a libref with the LIBNAME statement or using the New Library window. To use this method, enclose the filename, or the filename and
For example, in a directory based system, if you want to create a data set named MYDATA in your default directory, that is, in the directory that you are running SAS in, you can write the following line of code:
data 'mydata';
SAS creates the data set and remembers its location for the duration of the SAS session.
If you omit the single quotation marks, SAS creates the data set MYDATA in the temporary WORK subdirectory, named WORK.MYDATA:
data mydata;
If you want to create a data set named MYDATA in a library other than the directory in which you are running SAS, enclose the entire path in quotation marks, following the naming conventions of your operating environment. For example, the following DATA step creates a data set named FOO in the directory C:\sasrun\mydata.
data 'c:\sasrun\mydata\foo';
This method of accessing files works on all operating environments and in most contexts where a libref.data-set-name is accepted as a SAS data set. Most data set options can be specified with a quoted name.
You cannot use quoted
SAS catalogs
MDDB and FDB references
contexts that do not accept a libref, such as the SELECT statement of PROC COPY and most PROC DATASETS statements
PROC SQL
DATA step, stored programs, or views
SAS Component Language (SCL)
|
Operating Environment |
Examples |
|---|---|
|
DOS, Windows |
data 'c:\root\mystuff\sasstuff\work\myfile'; |
|
UNIX |
data '/u/root/mystuff/sastuff/work/myfile'; |
|
z/OS |
data 'user489.mystuff.saslib(member1)'; /* bound data library */ data '/mystuff/sasstuff/work/myfile'; /* UNIX file system library */ |
|
Open VMS Alpha |
data 'filename filetype filemode'; |
You can use operating environment commands to copy, rename, and delete the operating environment file or files that make up a SAS data library. However, to maintain the integrity of your files, you must know how the SAS data library model is implemented in your operating environment. For example, in some operating environments, SAS data sets and their associated indexes can be
| Caution |
Using operating environment commands can damage files. You can avoid problems by always using SAS utilities to manage SAS files. |