David Kantor and P. Wilner Jeanty:
Beth wrote me offlist to say all is well now, so I suspect my example
clarified something. However, there seems to be lingering confusion.
P. Wilner Jeanty claims that in his first example, a tempfile
"vanishes itself" at the end of execution. I suspect P. Wilner Jeanty
is copying his code into a do-file and running it, rather than copying
the code directly to the Command window. When a do-file finishes
executing, locals defined in that file are released from memory, and
tempfiles are erased, much as happens when a -program- stops
executing. So if you copy the part of the code that defines tempfiles
to a do-file, run it, then try to reference the tempfiles, they will
be gone. If you copy the code directly to the Command window, they
will still be there. This is as expected if you understand the
behavior of locals.
Here is a simple example which requires you to save a section of code
to a do-file:
----------------do file test.do-----------------
clear all
tempfile f
range id 0 1 2
save `f'
clear
desc using `f'
----------------end test.do-----------------
do test
desc using `f'
di "$file"
desc using $file
On Jan 7, 2008 9:31 PM, David Kantor <[email protected]> wrote:
> Looking at example 1, it saves two files, but at the end, it just has
> what is present after creating the second dataset, d_student (and
> saving it, which is actually irrelevant); it makes no use of the
> first file after it is saved.
<snip>
*
* 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/