Yes, but Stata also assumes that you are smart and capable of thinking
about what you are doing.
If you say -clear- then Stata doesn't come back with "are you sure?"
even if you have been on-line for a very long time and that -clear-
might lose a massive amount of work.
-preserve- is intended mostly for programmers, as the online help
indicates. It appears in many programs, and usually the -restore- is
automatic when the program terminates.
As said before, I agree with you that -preserve- used interactively can
bite. And as said before, you can program your way around that by
writing a wrapper that protects you against the main problem. That being
so, I see no case for any change to -preserve-.
Martin Weiss
Nick,
fair enough, but it should be possible to advise just the way Stata
advises
if the change flag for the dataset is 1. Fortunately, it gives a warning
as
to the changed nature of the data you are about to destroy and prevents
you
from doing stupid things. I remember reading a section in the handbooks
about how Stata is so very careful with commands that may change your
data
in undesirable ways. Should the same not happen for -preserve-d data?
Nick Cox
I think this is mostly on the level of yes, sharp knives can cut you if
you are not careful.
As I understand it,
preserve
...
save
...
does not rule out a subsequent -restore-.
But otherwise yes, you can get bitten if you forget what you have done.
It would be easy enough to write a command that -save-d while it
-preserve-d, but
you would have to remember to use it. I can't see an advantage in
advising that
over advising the use of -save- before -preserve- when that's a good
idea -- or indeed over recommending -save- and avoiding -preserve- if
you are going to forget what you have done.
Martin Weiss
I was wondering if anyone apart from me has been bitten by -preserve-? I
recently preserved data, then dropped half my data to carry out some
calculations and later forgot the preserve-status and saved. Now call me
foolish, but in the heat of the action, it is easy to forget about the
status of your data, isn`t it?
So: is there a mechanism to alert me to this danger, and if not, should
there be one?
*
* 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/