Statalist


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

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


From   "Kim Lyngby Mikkelsen (KLM)" <klm@arbejdsmiljoforskning.dk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: SV: How to restore dataset after preserve, but keep some specific variables?
Date   Thu, 25 Jun 2009 16:05:32 +0200

Hallo Christoph

At the end of each rounds, save the new variables together with a unique identification variable, and then restore.

After restore, you can merge in the saved variables.

Rerards
Kim

Kim Lyngby Mikkelsen
Seniorforsker
Arbejdsulykker og Sikkerhed
Det Nationale Forskningscenter for Arbejdsmiljø
 
-----Oprindelig meddelelse-----
Fra: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] På vegne af Stata Chris
Sendt: 25. juni 2009 16:00
Til: statalist@hsphsun2.harvard.edu
Emne: st: How to restore dataset after preserve, but keep some specific variables?

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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index