Search
>> Home >> Resources & support >> FAQs >> Using the STATATMP environment variable

### Why am I getting an error message that there is “insufficient disk space”?

 Title Using the STATATMP environment variable Author Pete Huckelba, StataCorp Date February 2003; updated December 2006

Some routines within Stata will use the preserve and restore commands or will attempt to write temporary files to aid in processing. If your machine is limited in hard-drive space, or if the partition is near its capacity, Stata may report an error similar to

        insufficient disk space
r(699);


By default, Stata will save temporary files in the directory pointed to by the TEMP (Windows) or TMPDIR (Linux/Unix) environment variable. You also have the option of setting up the environment variable, STATATMP, to point to a location other than the predefined variables listed above. The usage of STATATMP is preferred because some operating systems may not allow you to modify the path of TEMP or TEMPDIR unless you have administrative or root access.

If your machine has free space on another physical drive or partition, you can instruct Stata to save its files to that location to prevent the error. Depending on the method used, you will have to terminate the current Stata session and may have to log out or reboot the machine.

To verify the location of the temporary directory Stata is using, type the following commands from within Stata:

        . tempfile junk
. display "junk'"
`

Ignore the filename and look at the directory—this is where Stata is saving temporary files. Using your operating system's tools, you can verify if that location is actually near its limit.

### Temporary fix

Using your favorite editor, create a file with the following contents:

• Windows users
set STATATMP=drive:\path\to\location
cd drive:\path\to\start in directory
drive:\path\to\Stata binary
You can then save that file as a batch (filename.bat) to your desktop and run it as needed.
• Linux/Unix users (shell independent)
STATATMP="/path/to/location"
export STATATMP
cd /path/to/start in directory
/path/to/Stata binary
After you have saved the file, you will need to make it executable by issuing chmod u+x filename from your OS command line or terminal. You can then run Stata with the modified environment by typing the name of the file you just created.

### Permanent Fix

• Windows 95/98/ME users will need to edit the autoexec.bat file located in the root drive (generally C:\). It is recommended that you make a backup of the autoexec.bat file so that you can easily revert the change if needed. Simply add the line
set STATATMP=drive:\path\to\location
in the area where the other environment declarations are made or at the end of the file if there are not any other declarations. Next reboot the machine, and Stata will use the STATATMP directory the next time it is called.
• Windows NT users should access the Control Panel by clicking Start, Settings, and then Control Panel. Double-click the System icon and click the Environment tab. Type STATATMP in the Variable box and specify the path where the temporary files should be saved in the Value box. Click Set, followed by the Apply button. Next reboot the machine, or log out and back in, and Stata will use the STATATMP directory the next time it is called.
• Windows XP/2000/Vista users should open the Control Panel (Vista users will have to switch to classic view via the link on the left-hand side of the Control Panel), double-click the System icon and click the Advanced tab/link, and then select the Environment Variables button. Under the User variables section for your login ID, click New, enter STATATMP for the Variable Name, and specify a path for the Variable Value. Click Ok to close the New User Variable Window, Ok to close the Environment Variable window, and Ok again to close the System Properties. Next reboot the machine, or log out and back in, and Stata will use the STATATMP directory the next time it is called.
• Linux/Unix users can modify the shell profile located in their home directory. Using an editor, csh and tcsh users can add
setenv STATATMP "/path/to/directory"
to their .cshrc or .tcshrc file. Bash users will need to add the declarations
STATATMP="/path/to/location"
export STATATMP
in their .bashrc file. You can then re-source the environment or log out and log back in to activate the change.

Note: Both of the methods listed above require that the directory exists before attempting to set the environment variable.