Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Creating new variable from existing observations
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Creating new variable from existing observations
Date
Sat, 9 Jun 2012 09:19:03 +0100
I don't think I understand all of this, but these calculations may be
suggestive
egen lastM = max(YEAR / (M_Treat == 0)), by(Xcode Mcode)
egen lastX = max(YEAR / (X_Treat == 0)), by(Xcode Mcode)
egen valueM = min(M_imp / (YEAR == lastM)), by(Xcode Mcode)
egen valueX = min(M_imp / (YEAR == lastX)), by(Xcode Mcode)
On Sat, Jun 9, 2012 at 1:00 AM, Suryadipta Roy <[email protected]> wrote:
> Dear Statalisters,
>
> I am trying to create the last column (i.e. the variable M_imp_new)
> where the data take the following form:
>
> Xcode Mcode YEAR X_exp M_imp X_Treat M_Treat M_imp_new
> CAN MEX 1990 2 8 1 0 8
> CAN MEX 2000 3 9 1 1 8
> CAN MEX 2010 4 9 1 1 8
> MEX CAN 1990 8 2 0 1 2
> MEX CAN 2000 9 3 1 1 2
> MEX CAN 2010 9 4 1 1 2
> US CAN 1990 2 2 0 1 2
> US CAN 2000 1 3 0 1 2
> US CAN 2010 3 4 1 1 2
> US MEX 1990 2 8 0 0 8
> US MEX 2000 1 9 0 1 8
> US MEX 2010 3 9 1 1 8
> MEX US 1990 8 2 0 0 1
> MEX US 2000 9 1 1 0 1
> MEX US 2010 9 3 1 1 1
> CAN US 1990 2 2 1 0 1
> CAN US 2000 3 1 1 0 1
> CAN US 2010 4 3 1 1 1
>
> The M_imp_new is supposed to take the value of M_imp before M-treat
> changes from 0 to 1 for each country. E.g. for MEX, M-imp = 8 in
> year==1990 (M-treat=0) and then MEX experienced the treatment such
> that M_Treat = 1 in year==2000. Thus, M_imp_new= 8 for MEX.
*
* 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/