Neville Young ([email protected]) asked about a problem saving
a file across a Windows network:
> What seems to be happening is this:
>
> You save a file, several times in a row, same filename. It�s fine.
> You then do "save as" and try to save it with a different filename. It then
> *sometimes* claims that the new, different filename already exists, and
> fails to save.
>
> Here�s an example:
>
> . save "H:\03 Computing\SOFTWARE\Stata\anothername.dta", replace
> file H:\03 Computing\SOFTWARE\Stata\anothername.dta saved
> ...
> . save "H:\03 Computing\SOFTWARE\Stata\anothername2.dta"
> file H:\03 Computing\SOFTWARE\Stata\anothername2.dta already exists
> r(602);
>
> - but in fact the file anothername2.dta did NOT exist. It worked next try,
> with the same name.
I just checked Stata's source code to see in what situations an "r(602)"
error can be returned after a -save- command. There is only one reason
that it is returned.
When Stata tries to save a file, and the 'replace' option has not
been specified, Stata first tries to open the file read-only (using
the standard C function 'open()' to see if it exists. Stata won't
let you overwrite an existing file if the 'replace' option has not
been specified.
If the C function 'open()' opens the file and successfully returns
a valid handle to that file, Stata will then return an r(602) error
if the 'replace' option has not been specified on -save-. This
is the ONLY way this error can occur.
I have only a guess as to why Windows (or whatever networking software
Neville's site is using) might be returning a valid file handle to
open() when no file exists. Perhaps there is some sort of caching
issue where if a file with that name existed at some point in the past,
but does not exist now, Windows (or whatever netowrking software
Neville's site is using) still thinks it exists and is returning
a valid handle to a file which in reality no longer exists. This is
an issue Neville will need to take up with his network vendor.
It would be interesting to know what happened if the ", replace" option
were always specified with -save-. This might allow Neville to work
around the problem.
--Alan
([email protected])
*
* 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/