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   "Rajesh Tharyan" <R.Tharyan@exeter.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: -replace- should not be use with temporary files (was: Comparing datasets)
Date   Thu, 18 Sep 2008 18:22:08 +0100

Hi,

When would one want to save replace a temp file. Given that, it will get
erased at the end of the run? One can just create as many as needed is it
not? Or would that be inefficient vis--vis usage of system resources?

Rajesh



-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Steven Samuels
Sent: 18 September 2008 18:08
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: -replace- should not be use with temporary files (was:
Comparing datasets)

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
> n.j.cox@durham.ac.uk
>
> 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/


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index