Using SAS Files |
The Importance of Disk Space in the Work Library |
Disk space is the aspect of the Work library that is most likely to require your consideration. If you have many large temporary SAS data sets, or if you use a procedure that has many large utility files (for example, a PROC FREQ step with a complex TABLES statement that you run against a large SAS data set), you might run out of disk space in the Work library. If you run out of disk space in batch mode, your PROC or DATA step terminates prematurely and issues a message similar to the one shown in the following output. In an interactive session, a dialog box asks you to specify what action to take.
Insufficient Work Library Space Message
ERROR: Insufficient space in file WORK.DATASET.DATA. NOTE: The SAS System stopped processing this step because of errors. NOTE: SAS set option OBS=0 and will continue to check statements. This may cause NOTE: No observations in data set. WARNING: The data set WORK.DATASET may be incomplete. When this step was stopped there were 22360 observations and 4 variables. ERROR: Errors printed on page 1.
To resolve the problem of insufficient Work space, ask your system administrator to increase the disk quota that has been assigned to you, or ask for the disk to be cleaned up. Here are several methods of increasing your Work library space:
Designate a disk with more space as your Work library. (See Changing the Location of the Work Library.)
Delete each temporary SAS data set as soon as you no longer need it. (See Deleting Temporary SAS Data Sets.)
Direct the temporary SAS data sets to a different SAS library so that disk space in the Work library is conserved for items that must be stored there. (See Directing Temporary SAS Data Sets to the User Library.)
Reduce the version limit on the directory in which the Work library is created.
The Work Library Subdirectory |
By default, a subdirectory of the current directory contains the Work library. The name of the subdirectory that SAS creates for your Work library is SAS$WORKcurrent-pid_timestamp. Both current-pid and timestamp are unique values that are assigned by OpenVMS. The current-pid value is an 8-byte process-identification value and the timestamp value is an 8-byte value of the time, in seconds, when the Work library was created.
When SAS creates the Work subdirectory, it also creates an OpenVMS process-level logical name, SAS$WORKLIB, that references the Work library. You can use this logical name within the SAS session to reference files in the Work subdirectory. It remains defined after the SAS session terminates.
Changing the Location of the Work Library |
You can change the location of the Work library either by redefining the OpenVMS logical name SAS$WORKROOT, which references the current directory, or by specifying the WORK= system option. For example, the following SAS command tells SAS to create the WORK subdirectory in the directory DISK:[XDIR]:
$ SAS92/WORK=DISK:[XDIR]
SAS$WORKROOT refers to SYS$DISK:[ ] by default, but your system manager might have redefined it. The default might be changed when SAS is installed by your system manager.
Deleting Temporary SAS Data Sets |
Under OpenVMS, temporary SAS data set means a data set that is stored in a temporary SAS Work library. That is, you cannot designate the data set itself as temporary, but the data set takes on the attribute of the library in which it is stored.
One simple way to conserve space in the Work library is to delete each temporary SAS data set with a PROC DATASETS step after you no longer need it. However, there are two problems with this method.
You can cause errors in a job by deleting a SAS data set before the job is finished with it.
If you need several very large temporary SAS data sets in your job at the same time, you might run out of space before you reach a point at which you can delete any SAS data sets.
Directing Temporary SAS Data Sets to the User Library |
An alternative to deleting the temporary SAS data sets is to direct them to a different SAS library. You can use the USER= system option to store temporary data sets in the User library rather than in the Work library. Unlike the Work library, when you use the User library to store temporary files, these files are not automatically deleted when SAS terminates.
Note: Utility data sets that are created by SAS procedures continue to be stored in the Work library. However, any data sets that have one-level names and that are created by your SAS programs will be stored in the User library.
The following example illustrates the use of the USER= system option. The numbered lines are explained following the code.
filename giant 'mydisk:[survey]tvdata.dat'; libname result 'mydisk:[sasdata]'; 1 libname temp 'disk2:[temp]'; 2 options user=temp; 3 data totalusa; infile giant; input home_id region income viewers cable; if home_id=. then delete; run; 4 proc freq; tables region*income*viewers*cable 5 / noprint out=result.freqdata; run;
Note: You can also assign the USER libref directly by using the LIBNAME statement as follows:
libname user '[mydir]';
You can specify the USER= system option in the SAS command, as in the following example:
$ SAS92/USER=[MYDIR]
System Options That Control the Work Library |
Two system options control the creation and deletion of the WORK subdirectory. By default, the WORK subdirectory is deleted at the end of each SAS session, and a new one is created at the beginning of the next session. The WORKTERM system option controls the deletion of the WORK subdirectory, and the WORKINIT system option controls the creation of the new subdirectory.
The WORKTERM and WORKINIT system options are valid in all operating environments and are documented in SAS Language Reference: Dictionary.
The default value of the WORKINIT system option is WORKINIT, and SAS automatically creates a WORK subdirectory as it initializes. If you specify NOWORKINIT, SAS looks for an existing WORK subdirectory in the current directory and uses it, as is, if it exists. If it does not exist, one is created. You can specify the WORKINIT system option in the SAS command or in a configuration file.
If you have logged out of your OpenVMS process since the previous WORK subdirectory was saved, SAS cannot find the Work library even if you specify NOWORKINIT, so it creates a new Work library. This is because your OpenVMS process ID has changed and the subdirectory name includes the OpenVMS process ID. In this case, the old Work library still exists (it was not written over), and you can assign a new libref to the old WORK subdirectory (SAS$WORKold-pid_timestamp) after you get into your SAS session and use the files through the new libref. Search the default directory for the old SAS session to find the old WORK subdirectory name. You can use the X statement within your current SAS session to perform this directory search.
The WORKTERM option controls whether the WORK subdirectory is deleted at the end of your SAS session. The default value is WORKTERM. If you specify NOWORKTERM, the WORK subdirectory is not deleted at the end of the session and remains available for use with the next SAS session. Remember, however, that you must specify NOWORKINIT in the next invocation of SAS to reuse the WORK subdirectory that you saved.
The CLEANUP Tool |
Under OpenVMS, the CLEANUP tool is available to conveniently delete the Work library or a utility file directory that was assigned by the UTILLOC system option. When a SAS session terminates normally, the Work library and any utility file directories are deleted automatically (this is the default action). However, if your SAS session terminates abnormally, the Work library and the utility file directories might not be deleted properly. To delete the Work library or a utility file directory, use the CLEANUP tool.
If you inadvertently delete the Work subdirectory that was created for a batch job, the job abends. Also, never issue the CLEANUP command from an OpenVMS subprocess.
If the CLEANUP tool is not available at your site, contact your on-site SAS Support personnel.
To access the CLEANUP tool, complete the following steps:
Create a DCL symbol that points to the executable image. This symbol or foreign command can be added to the SAS92.COM file. The symbol CLEANUP is used in the following example:
$ CLEANUP == "$SAS$ROOT:[UTILITIES.BIN]CLEANUP.EXE"
Issue the CLEANUP command from your DCL prompt to delete Work libraries from one or more directories. For syntax information, see Syntax Variations of the CLEANUP Command.
For each Work library that exists in the specified directory, the CLEANUP tool issues the question
OK to delete device:[dir]SAS$WORKnnnnnnnn.DIR;1 [YES]?
where device:[dir] is the name of the disk and directory to which you were attached when you invoked SAS, and SAS$WORKnnnnnnnn.DIR;1 is the subdirectory that contains the Work library. YES is the default response, so to execute the CLEANUP command, press the ENTER key. When the CLEANUP tool executes, it lists the names of the files being deleted. If the specified directory contains more than one WORK subdirectory, the CLEANUP tool then issues the previous question for the next Work library.
Note: This behavior is the same if you are deleting a utility file directory.
The following are some syntax variations to be aware of:
$ CLEANUP
$ CLEANUP [.TEMP]
$ CLEANUP [...]
The CLEANUP command accepts the following qualifiers:
/LOG is the default. This causes the CLEANUP tool to issue a message showing each file as it is deleted, and it shows how many directories were deleted. If you specify /NOLOG, no messages are issued unless the CLEANUP tool encounters an error while trying to delete one or more files.
/CONFIRM is the default. This causes the CLEANUP tool to prompt you for each directory to be deleted. The default is Y for yes if you press Enter. If you do not want to be prompted, or if you are submitting the command from a batch job, then use /NOCONFIRM.
This qualifier deletes all SAS work directories created on or before the specified date.
Note: The /V5 | /NOV5 and /V6 | /NOV6 options for the CLEANUP command are no longer supported.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.