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/