In the code you have below, the "if" has to be before the comma:
factor wbq91-wbq93 if year == 2005, factors(1)
Best,
Doug
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of C.T. Shehzad
Sent: Monday, November 09, 2009 10:04 AM
To: [email protected]
Subject: Re: st: AW: Keeping variable After restore
Dear Martin:
Thanks for your reply. However, stata says "option if not allowed". It
has happened before as well that conditionals do not work as option.
factor wbq91-wbq93, factors(1) if year == 2005
option if not allowed
r(198)
Thanks again and best regards,
Tanveer
Martin Weiss wrote:
<>
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...
HTH
Martin
-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von C.T. Shehzad
Gesendet: Montag, 9. November 2009 15:22
An: [email protected]
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:
preserve
keep if year == 2000
factor x1 x2 x3
predict var1
restore
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,
Tanveer
*
* 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/