Several questions were asked yesterday regarding Stata temporary
files. We have put together a FAQ explaining temporary files in
Stata:
1. What is a temporary file?
A temporary file is a file on disk that an application creates
while it is running which it uses to keep track of what it is
doing. The file exists only while the application is running and
is erased when the application exits.
2. How many temporary files does Stata create and use?
Stata creates one temporary file when it comes up (one per Stata
session running), and then creates more files to help it keep
track of its windowed interface. In addition, users, ado-files,
and do-files can create temporary files using Stata's -tempfile-
command.
3. When are temporary files erased?
Temporary files created by an application such as Stata are erased
when you exit the application -- if not before -- but they are
erased only if you follow the application's usual shutdown
procedure. In Stata, any temporary files created within an
ado-file or do-file are erased as soon as that ado-file or do-file
exits, even if it exits with an error. If the application
crashes, or if you just reach up and shut off your computer, the
temporary files will not be erased.
4. Does that matter?
It matters only because the files consume disk space. Almost
everybody's system has a few old temporary files hanging around.
5. How can I find out if I have any hanging around?
Look in the directory where temporary files are stored.
6. Where does Stata store temporary files?
That can vary from system to system. The easy way to find out is to
type:
. tempfile findout
. display "`findout'"
The last line will produce output such as
. display "`findout'"
C:\Windows\TEMP\ST_07000001.tmp
The last part is an example of a temporary file name. The
first part is where the files are stored:
C:\Windows\TEMP\ST_07000001.tmp
|--------------|--------------|
/ \
Temporary a particular temporary file name.
directory
7. Oops! I see my system has lots of temporary files. Can I erase them?
Yes, but cautiously. Not all the temporary files in the temporary
directory necessarily belong to Stata. They may have to do with
other applications.
As a rule, you may erase an application's leftover temporary
files, but only if that application is not currently running.
Otherwise, those files may not be leftovers but active and
important files for that application.
8. How can I tell if a temporary file belongs to Stata?
In Windows, all Stata temporary files begin with 'ST' followed by
another character, then a sequence of numbers or letters, and
finally ".tmp". Example filenames are
ST_07000001.tmp
STi04000007.tmp
STG03000024.tmp
--|--------
/ | \
Always | \
'ST' | This sequence changes.
|
This character changes to one of D, G, H, i, J, Q, _, or W.
In Unix and Macintosh, all Stata temporary files begin with 'S'
followed by another character, then a sequence of numbers or letters,
then a '.' followed by another sequence of numbers. Example filenames
are
SQ31382.000001
Si31618.000005
S_31618.000357
-|----- ------
/ | \ /
Always | \/
'S' | These sequences change.
|
This character changes to one of D, G, H, i, J, P, Q, t, or W.
9. And I can erase those files?
Yes, if Stata is not running.
More interesting is why you have such files. Stata erases its
temporary files when you exit normally, either by typing -exit- or
pulling down File and choosing Exit. The only way temporary files
could be left behind is if something has caused Stata to crash or
if the computer has not been shut down normally.
If any users think they have an unusual number of temporary files
sitting around even after all instances of Stata have been shut down,
our Technical Services group ([email protected]) will be happy to
help them diagnose the issue and to assist them with removing any
leftover temporary files.
--Alan
([email protected])
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/