Chapter Contents |
Previous |
Next |
SAS Companion for the CMS Environment |
Writing to SAS Files on Disk |
To write a disk-format SAS file, you usually need only to specify the two-level filename in the appropriate SAS statement. That is, in most cases you do not need to assign a libref to the file because SAS automatically assigns librefs for permanent SAS files on disk. (However, see When to Assign a Libref for a SAS File on Disk for exceptions and for performance considerations.) For example, suppose you specify the SAS filename MYLIB.TASTEST in a SAS statement. In CMS terms, this is equivalent to filename TASTEST and filetype MYLIB:
SAS name | CMS name | |
MYLIB.TASTEST |
TASTEST
MYLIB |
|
libref.filename | filename filetype |
Because the SAS filename includes no filemode or directory identifier, SAS uses the following procedure to determine where to write the file:
Reading SAS Files on Disk |
To read an existing SAS file that is in disk format, you usually need only to specify the two-level filename in the appropriate SAS statement. That is, in most cases, you do not need to assign a libref to the file. (However, see When to Assign a Libref for a SAS File on Disk for exceptions and performance considerations.) For example, suppose you specify the SAS file MYLIB.TASTEST in a SAS statement. In CMS terms, this is equivalent to filename TASTEST and filetype MYLIB:
SAS name | CMS name | |
MYLIB.TASTEST |
TASTEST
MYLIB |
|
libref.filename | filename filetype |
Because the SAS filename includes no filemode or directory identifier, SAS uses the following procedure to locate the file:
Note: If the file exists on more than one minidisk or directory, SAS stops searching
as soon as it finds the first TASTEST MYLIB file. If you have multiple files
with the same name and filetype on different minidisks or directories, and
you want to read a file that would not be located first according to the standard
search order, then you must assign and use a libref.
When to Assign a Libref for a SAS File on Disk |
Under CMS, when you are reading from and writing to disk, you do not always have to assign a libref. (See Reading SAS Files on Diskand Writing to SAS Files on Disk for explanations of why librefs generally are not required for disk-format files.) You may want to do so, though, for portability and clarity.
In the following examples, filemode can be specified in either of two ways:
You should assign a libref under the following circumstances:
LIBNAME libref 'physical-name'; |
A physical name can be specified as either a filemode or an SFS directory.
For example:
LIBNAME MYLIB '.MYLIB'; |
LIBNAME libref 'filetype filemode'; |
For example:
LIBNAME MYLIB 'REPORTS A';
LIBNAME libref engine 'physical-filename'; |
For example:
LIBNAME MYLIB V6 'REPORTS A';
Note: If you omit the engine argument,
BASE is assumed by default.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.