In SAS or Stata, how do I redirect temporary work files?

Temporary work files (or "scratch files") created during SAS or Stata sessions may exhaust your available disk space. As a result, your session will terminate with an error message indicating you have insufficient disk space to complete the job. To avoid this problem, you can instruct SAS or Stata to redirect temporary work files to free space in a local or shared scratch directory.

At Indiana University, the Data Capacitor II (DC2) high-speed file system provides scratch space for users on Big Red II and Karst. If you have an account on one of those systems, you can access your DC2 scratch directory at /N/dc2/scratch/username (replace username with your Network ID username). Additionally, Karst users have access to local scratch space located at /tmp.

On this page:


Redirecting SAS work files

To redirect temporary work files created during an SAS session, add the -work option to your SAS command line to specify the path to the desired scratch directory.

For example, if your SAS program is called my_file.sas:

  • Local scratch: On Karst, to redirect work files to local scratch space (/tmp), on the command line, enter:
      sas -work /tmp my_file.sas
    
  • DC2 scratch: On Big Red II or Karst, to redirect work files to your DC2 scratch directory, on the command line, enter (replace username with your Network ID username):
      sas -work /N/dc2/scratch/username my_file.sas
    

When your SAS session is complete, the resulting .log and .lst files will be stored in the default directory, and SAS will remove the redirected work files.

Redirecting Stata work files

To redirect temporary work files created during Stata sessions, set up the STATATMP environment variable to point to the desired local or DC2 scratch directory. To make the setup permanent, add the STATATMP environment variable to the shell profile in your home directory (and then log out and log back in to activate the change).

For example, to redirect Stata work files to the local /tmp scratch directory on Karst:

  • In bash, add these lines to the .bashrc file:
      STATATMP="/tmp"
      export STATATMP
    
  • In tcsh, add this line to the .tcshrc file:
      setenv STATATMP="/tmp"
    

Alternatively, to redirect work files to your DC2 scratch directory, add the same lines, but change "/tmp" to "/N/dc2/scratch/username" (replace username with your Network ID username).

This is document addl in the Knowledge Base.
Last modified on 2018-05-30 14:27:59.

Contact us

For help or to comment, email the UITS Support Center.