Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: Generating tempfiles within a program for later use


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Re: Generating tempfiles within a program for later use
Date   Tue, 8 Jan 2008 22:40:26 -0500

Beth--
As David Kantor and I have said, as soon as you exit the context where
a tempfile is named, be that a -program- or a do file, the tempfile is
erased. So if you interrupt things as they execute, all tempfiles
should disappear.  There is no need to specify -replace- when you save
a tempfile; in fact, this can only create problems.  Also, note that
you are not in general allowed (by law) to create tempfiles with
confidential data, for example when your temp directory is on an
unencrypted drive C: and your confidential data is on a encrypted
drive D: --but you can always save files to a custom temp directory
then erase them all when done like so:

program define p_school, rclass
 clear
 odbc load, dsn("MS Access Database; DBQ=$dbname") table("tblSchool") lowercase
 compress
 save `0', replace
end

clear
mkdir tmp
global d_school "tmp/f1"
p_school $d_school
global d_student "tmp/f2"
p_student $d_student
global d_attendees "tmp/f3"
p_attendees $d_attendees
global d_meetings "tmp/f4"
p_meetings $d_meetings
mmerge studentmtgid using $d_attendees
mmerge studentid using $d_student, ukeep(studentid schoolid)
mmerge schoolid using $d_school
$sample
local files : dir "tmp" files "*.dta"
cd tmp
foreach f of local files {
  erase `f'
  }
cd ..
rmdir tmp

On Jan 8, 2008 6:43 PM, Beth Gifford <[email protected]> wrote:
> Not quite
> I am running this as a program (well a series of programs).  As long as I do
> not interrupt anything, the program runs fine and the merge works.  If I
> interrupt it though it doesn't.  You can see in the second program I merge
> several temporary files with success (hope that isn't wrong)!
> -Beth
*
*   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/



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