How to redirect Stata temp file to a specific folder

Sometimes the default Stata temp space run out of space so you may have to redirect the location of your temp file. Here’s what you should do.

Open Notepad.

Paste the following:
set STATATMP=u:\statatemp
cd u:\project
“C:\Program Files (x86)\Stata14\statamp-64.exe”

Make sure you create u:\statatemp folder mentioned on the set command above. You can specify any path\folder here provided they exist. This is where Stata will redirect your temp files.

Replace the u:\project folder with your own project path\folder (or your work directory).

Don’t touch the last line. The point of the last line is to run the .exe file that would open stata. If you are using a different Stata version the path\folder and .exe name may be different, so you may have to replace the last line with the correct one.

Save the notepad file as a batch file i.e., with a .bat extension (e.g., Statatemp.bat). Do not save it with the default .txt extension. It has to have a .bat extension.

Once created, double-click on the .bat file.

You open Stata by double-clicking on this .bat file. That is how you should start your Stata session from hereon. Best if you store this .bat file on the desktop for easy access.

Once stata is open. You can run these commands to check where your tempfile is going:

tempfile junk
display “`junk'”

It should show the temp file being stored in the folder you specified on the set command.


Quick Links