--- Martin Weiss <[email protected]> wrote:
> Nick and Maarten both steered you the way of -egen- which does indeed
> solve your problem. Note, though, that -egen- creates new variables,
> i.e. adds a new column to your dataset. Depending on your # of obs,
> that can be quite wasteful, and students often forget to drop these
> vars afterwards. Instead, they save them with the dataset which
> creates unnecessary confusion. If all you want is the dummy you asked
> for, you are probably better off conserving returned values in a
> -local- and -generate-ing your dummy based on the -local-...
Another take on this is that you should only save your .do file and
never save your data (exept when you first enter the raw the data of
course). There are several reasons for this advise:
First, this way you have an exact record of what you have done to your
data.
Second, if you make a mistake (which will always happen) then it can
usually be quickly fixed if you have the .do file, but it will be a
complete nightmare when all you have is saved data. (i.e. you will have
to do everything over again, which means you will just make some other
error that needs to be fixed later on, etc.)
I have used this method for all the analyses and data-preparations I
did for the chapters of my dissertation. I am now in the process of
bringing those chapters together and checking the analyses, and now I
am very very very very very very very happy I have done it this way.
With minimal effort I can now exactly reproduce my results, make sure
all the analyses are done on comparable data, etc.
Anyhow, if you do your data preparation in a .do file than it may
actually be clearer not cram as much operations into one line of code
and be a bit wasteful with memory by creating intermediate variables,
as it usually makes your code easier to read (don't forget to add
comments, having to re-read code a wrote years ago gave me renewed
appreciation of the usuefulness of comments)
-- Maarten
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* 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/