Title | Using the STATATMP environment variable | |
Author | Pete Huckelba, StataCorp |
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.
Using your favorite editor, create a file with the following contents:
set STATATMP=drive:\path\to\locationYou can then save that file as a batch (filename.bat) to your desktop and run it as needed.
cd drive:\path\to\start in directory
drive:\path\to\Stata binary
STATATMP="/path/to/location"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.
export STATATMP
cd /path/to/start in directory
/path/to/Stata binary
set STATATMP=drive:\path\to\locationin 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.
setenv STATATMP "/path/to/directory"to their .cshrc or .tcshrc file. Bash users will need to add the declarations
STATATMP="/path/to/location"in their .bashrc file. You can then re-source the environment or log out and log back in to activate the change.
export STATATMP
Note: Both of the methods listed above require that the directory exists before attempting to set the environment variable.