Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Creating new variable from existing observations


From   Suryadipta Roy <sroy2138@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Creating new variable from existing observations
Date   Fri, 8 Jun 2012 20:00:53 -0400

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. I have
been struggling with this for some time without success, and would
sincerely appreciate some help.

Thank you very much in anticipation!
Suryadipta.
*
*   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   |   Site index