Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Stata temporary files FAQ

From (Alan Riley)
Subject   st: Stata temporary files FAQ
Date   Fri, 23 Jan 2004 10:26:07 -0600

Several questions were asked yesterday regarding Stata temporary
files.  We have put together a FAQ explaining temporary files in

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-

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 

		. tempfile findout

		. display "`findout'"

    The last line will produce output such as

		. display "`findout'"

     The last part is an example of a temporary file name.  The 
     first part is where the files are stored:

                 /                 \
            Temporary               a particular temporary file name.

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

       /  |     \
 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

       -|----- ------
      / |    \  /
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 ( will be happy to
help them diagnose the issue and to assist them with removing any
leftover temporary files.

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index