SAS® Work library startup errors and how to change the Work library for temporary files to another drive on a Microsoft Windows operating system


The SAS® start-up errors "ERROR: Invalid physical name for library WORK", "ERROR: Insufficient authorization to access WORK library" and "ERROR: Library WORK does not exist" might require changing the location for the SAS Work library. Also, there are other reasons to change the SAS Work location, such as changing to a drive with more disk space available. The SAS Work library has to be defined prior to starting SAS. Once a SAS session is open, the SAS Work library cannot be reassigned within that SAS session. The SAS Work library contains temporary files that are used during a SAS session.

To determine the physical location of the SAS Work library within a SAS session, submit one of the following statements:

libname work list;
 
proc options option=work;
run;
 
View the log results that display the directory path for the SAS Work library.

You can also verify the SAS Work library location used in the SAS session by using the SAS Explorer window. Double-click Libraries. Right-click Work and select Properties. The full path is displayed under Levels.

On Microsoft Windows operating systems, the SAS Work library is set to the default value of !TEMP/SAS Temporary Files where !TEMP is a Windows environment variable. To see the value for the !TEMP environment variable on your machine, in the Windows Search box enter COMMAND PROMPT and open the COMMAND PROMPT window. Then, enter the following:

set temp

If the specified SAS Work directory path does not exist or operating system file permissions deny access to the directory, any or all of the following messages might appear when you attempt to start SAS:

ERROR: Insufficient authorization to access WORK library
 
ERROR: Library WORK does not exist.
 
ERROR: Invalid physical name for library WORK.
 
NOTE: Unable to initialize the options subsystem.
 
ERROR: (SASXKINI): PHASE 3 KERNEL INITIALIZATION FAILED.
 
ERROR: Unable to initialize the SAS kernel

How to change the location of the SAS Work library

To redirect the Work library to a different physical directory location might require assistance from your IT department if permissions errors occur during the steps below. Take these steps:

  1. Make a backup copy of the sasv9.cfg file.

The default location for this file is as follows:

    • SAS® 9.1C:\Program Files\SAS\SAS 9.1\nls\en
    • SAS® 9.2C:\Program Files\SAS\SASFoundation\9.2\nls\en
    • SAS 9.2 32-bit on an X64 operating system: C:\Program Files\SAS\SASFoundation\9.2(32-bit)\nls\en
    • SAS® 9.3C:\Program Files\SASHOME\SASFoundation\9.3\nls\en
    • SAS 9.3 32-bit on an X64 operating systemC:\Program Files\SASHOME\x86\SASFoundation\9.3\nls\en
    • SAS® 9.4C:\Program Files\SASHOME\SASFoundation\9.4\nls\en
    • SAS 9.4 32-bit on an X64 operating systemC:\Program Files\SASHOME\x86\SASFoundation\9.4\nls\en

      Note
      : If SAS 9.3 and SAS 9.4 are on the same machine, then the SAS 9.4 default location uses
      the SASHOME2 directory, instead of the SASHOME directory.

  1. Go to the Search box on your system and enter Notepad.
    • Then, it is important to right-click Notepad and select Run as administrator.
    • In Notepad, select File ► Open
    • Then, change the file types in the bottom right-hand corner from Text Documents (*.txt) to All Files (*.*).
    • On the left side of the Open window, select the C:\ drive. Navigate to the file in Step 1 and open it.
  2. In Notepad, locate the SAS System option setting -WORK "directory-path".
  3. Modify the -WORK "directory-path" setting to point to the new drive and directory. Do not change the setting to use a drive letter only. The user account must have full control permissions to the new directory path.

For example, to save all temporary files to the D: drive, change the -WORK option in the sasv9.cfg file to the following:

-WORK "D:\SASWORK\SAS Temporary Files"

  1. In Notepad, select File ► Save
    • If you receive a Permissions Denied message, close Notepad. 
    • Locate the sas9v.cfg file.
    • Right-click the file and choose Properties.
    • On the Security tab, add your user ID and grant full access. Then repeat Steps 2–5 again. 
  2. Exit Notepad.
  3. Restart the SAS session to use the new Work location.

SAS Work configuration tips for a SAS deployment shared by multiple user accounts

Each unique user account that launches SAS sessions on a shared machine requires its own respective Work library. One technique to separate Work libraries for multiple user accounts is to include the Windows environment variable !USERNAME in the specified directory path.    

Here is an example:

-WORK "D:\SASWORK\!USERNAME\SAS Temporary Files"            


To see the value for the environment variable !USERNAME, in the Windows Search box enter COMMAND PROMPT and open the COMMAND PROMPT window. Then, enter the following:

set username


Restart the SAS session to use the new Work location.

How to redirect the SAS Work library in the SAS start-up command of the "SAS 9.x (English)" application shortcut

You can add the -WORK option to the SAS start-up command in the SAS 9.x (English) shortcut. After you edit the shortcut, launch SAS by selecting the application item or icon to use the new SAS Work library directory path.

For example, if you right-click the SAS 9.4 (English) shortcut icon and select Properties, the Shortcut tab might have the following Target option:

"C:\Program Files\SASHOME\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHOME\SASFoundation\9.4\nls\en\sasv9.cfg"
 

To change the SAS Work library location, add the -WORK option to this command:

"C:\Program Files\SASHOME\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHOME\SASFoundation\9.4\nls\en\sasv9.cfg"
-WORK "D:\saswork"

Here is an example of the command-line syntax for a SAS deployment shared by multiple user accounts on a single machine:

"C:\Program Files\SASHOME\SASFoundation\9.4\sas.exe" -CONFIG "C:\Program Files\SASHOME\SASFoundation\9.4\nls\en\sasv9.cfg"
-WORK "D:\saswork\%username%"