Statalist


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

Re: st: dangerous preserve


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: dangerous preserve
Date   Sun, 20 Apr 2008 17:09:11 -0400

I'm with Svend and Phil - I would never make changes to my
data except with a do-file. (The only exception is that I
might -compress- a datafile which I have recieved from someone
else.) I always name such do-files according to the file they
-use- and -save-, eg, raw_work1.do would read in a source
file and save it out as -work1.dta-. Similarly, any analyses
I want to use are coded in separate do-files, which are named
accordingly, eg, -analyze1.do-, -tables.do-, etc.

I often have to go back to projects months or even years after
the paper has been published, and this way I can always figure
what I did. Plus, I never lose data...

cheers,
Jeph

Svend Juul wrote:
Martin Weiss wrote:
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?
Martin Weiss
================================================================
The most dangerous thing you did was probably not to use -preserve- and forget that, but to save your data using the SAME filename as before.
Here are a few, very simple, very logical, and very safe rules to follow:
1. Modifications intended to be permanent should be made in a do-file,
never interactively.
2. This do-file should start with a command reading data (typically
-use-) and end with a -save- command, saving the modified data with
a NEW name.
3. Give this do-file a name that tells what it does. My suggestion:
use a gen_ prefix: gen_alpha7.do is the to-file that generates the
new alpha7.dta dataset.
4. Don't mix data management activities and analysis commands in the same do-file.
You can find a more elaborate version of this advice in S. Juul: An
Introduction to Stata for Health Researchers. Stata Press 2006.
Take care!
Svend

________________________________________________________ Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 DK-8000 Aarhus C, Denmark Phone, work: +45 8942 6090 Phone, home: +45 8693 7796 Fax: +45 8613 1580 E-mail: [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/

*
*   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