Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: How to restore dataset after preserve, but keep some specific variables?


From   Stata Chris <[email protected]>
To   [email protected]
Subject   st: How to restore dataset after preserve, but keep some specific variables?
Date   Thu, 25 Jun 2009 09:59:33 -0400

Good morning,

I need to do similar calculations, generating a new variable, on
different subsamples of my dataset,
and was therefore planning to use the preserve command each time
before cutting the dataset,
and then, after having generated the respective variable, restore to
return to the full dataset.

The problem with this is that once I restore the data, my new variable
is gone as well.
I first thought I could store this in a local macro,
but when I wanted to summarize all macros at the end of the dofile, it
turned out Stata wanted to use the lost variable, having apparently
remembered only that the macro consisted of said variable, but not the
distribution of the variable itself.

So my question is: How can I after each of these rounds generally
return to the full dataset,
but keep the one new variable?

Many thanks and best regards,
Christoph
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index