Previous Page | Next Page

Using SAS Files

The Work Library under OpenVMS


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.
   

Methods of Increasing Disk Space

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:

You can also combine these methods.

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.


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.  [cautionend]


Example: Using the USER= System Option

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;

[1] The LIBNAME statement associates the libref TEMP with the directory DISK2:[TEMP].

[2] In the OPTIONS statement, the USER= system option designates the TEMP libref as the temporary SAS library. Any data sets that have one-level names and that are created by your SAS program will be stored in this library.

[3] A one-level name is used in the DATA statement. When the DATA step is processed, the SAS data set TEMP.TOTALUSA is created.

[4] Because the large TOTALUSA data set was directed to the TEMP library, there is more space available in the Work library for the utility files that the FREQ procedure requires.

[5] The SAS data set FREQDATA contains the results of the FREQ procedure. A two-level name is used to store FREQDATA in the permanent SAS library MYDISK:[SASDATA].

Note:   You can also assign the USER libref directly by using the LIBNAME statement as follows:

libname user '[mydir]';

  [cautionend]

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 WORKINIT System Option

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 System Option

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


When to Use 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.

CAUTION:
Do not use the CLEANUP tool if your default directory is also the default directory for a SAS batch job, and a SAS batch job is currently running.

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.  [cautionend]

If the CLEANUP tool is not available at your site, contact your on-site SAS Support personnel.


How to Delete Files with the CLEANUP Tool

To access the CLEANUP tool, complete the following steps:

  1. 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"

  2. 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.  [cautionend]


Syntax Variations of the CLEANUP Command

The following are some syntax variations to be aware of:

To clean the current directory of work files, type the following:

$ CLEANUP
To clean work files from [.TEMP], type the following:

$ CLEANUP [.TEMP]
To clean work files from an entire directory tree, type the following:

$ CLEANUP [...]

The CLEANUP command accepts the following qualifiers:

/LOG | /NOLOG

/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 | /NOCONFIRM

/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.

/DATE=dd-mm-yy

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.  [cautionend]

Previous Page | Next Page | Top of Page