Statalist


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

Re: st: RE: -replace- should not be use with temporary files (was: Comparing datasets)


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: RE: -replace- should not be use with temporary files (was: Comparing datasets)
Date   Thu, 18 Sep 2008 13:08:29 -0400

Joseph Coveny wrote:
This is news to me. I use -replace- all of the time with temporary
files. What did StataCorp technical support say was the matter with using
-save . . . , replace- with temporary files?


Steven Samuels wrote (excerpted):

. . . Technical support told me that "replace" should not be used when
saving temporary files.

Joseph

What happened was--I tried to save a temporary file `t2', without first defining it Stata did not issue an error message, and I had no clue as to where I'd gone wrong. (My only excuse-I was tired.) Kerry Kammire of StataCorp pointed out my error and went on to say that there were actually two syntax errors.

"The second syntax error -save, replace- prevented Stata from issuing an error
when `t2' is undefined. The -replace- option shouldn't be needed when using
temporary files because they are freshly created each time the procedure is
run."

Thus -replace- was unnecessary and, in this case, harmful.

-Steve

On Sep 18, 2008, at 12:22 PM, Nick Cox wrote:


This came up on the list a while back.

Suppose you mistype the local macro reference. Say you mean to type

save `myfile', replace

but you have a minute brainstorm and you type `myfil'. Further suppose
that local macro `myfil' is not defined. Then Stata sees

save, replace

which to Stata is perfectly legal and intelligible. Stata will overwrite
the original data file, which is not what you intended at all. Of
course, typos here and there can have all sorts of consequences, all of
which are strictly your fault, but this one could be catastrophic if
what you had in memory was only a small part of the data or nothing to
do with the dataset you last read in.

There may be other reasons for not doing this, but that's one.

Nick
[email protected]

Joseph Coveney



*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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