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

st: AW: Keeping variable After restore

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Keeping variable After restore
Date   Mon, 9 Nov 2009 15:28:17 +0100


Instead of -keep-ing the year 2000:

webuse bg2, clear
gen year=2000*(_n<200)+ /* 
*/ 2001*(_n>=200)
qui factor bg2cost1-bg2cost6  /* 
*/ if year==2000
predict var1

and off you go...


-----Ursprüngliche Nachricht-----
[] Im Auftrag von C.T. Shehzad
Gesendet: Montag, 9. November 2009 15:22
Betreff: st: Keeping variable After restore 

Dear Stata-listers:

I want to generate a variable during (preserve - restore) and want to 
use that after restoring the data. When I will restore data the variable 
will be dropped automatically. How can I keep the variable?

The data is time series and a simple version of my program is as follows:

keep if year == 2000
factor x1 x2 x3
predict var1

gsort -year
replace var1= var1[_n-1] if var1 >= .
xtset country year
xtreg dep var1 controls

The problem in this program is that after restoring the data I will not 
have var1 anymore. What can be a possible solution?

Thanks and best regards,


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2023 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index