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]
st: RE: Manipulating data in the time series dimension of unbalanced panels
From
Joe Canner <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: Manipulating data in the time series dimension of unbalanced panels
Date
Fri, 23 Aug 2013 16:29:34 +0000
Kurt,
Here's one possibility:
. gen Dummy2=Dummy1
. bysort Country (time): replace Dummy2=1 if Dummy1==1 | Dummy2[_n-1]==1
. replace Dummy2=. if Dummy1==. // unless you want Dummy2 to continue to have a value of 1 even if Dummy1 is missing
Regards,
Joe Canner
Johns Hopkins University School of Medicine
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, August 23, 2013 12:18 PM
To: [email protected]
Subject: st: Manipulating data in the time series dimension of unbalanced panels
Dear Statalist user,
This one is probably quite easy but I did not find a solution yet. Perhaps someone of you could help me?
I have an unbalanced panel data set with a binary dummy variable ("Dummy1"). Now I want Stata to generate a new dummy variable (Dummy2) which is coded 1 after the first dummy variable once took the value 1.
Example:
time Country Dummy1 Dummy2
2000q1 1 . .
2000q2 1 0 0
2000q3 1 0 0
2000q4 1 1 1
2001q1 1 0 1
2001q2 1 0 1
2000q1 2 0 0
2000q2 2 1 1
2000q3 2 0 1
2000q4 2 0 1
2001q1 2 0 1
2002q1 2 . .
Thanks for your effort and best regards, Kurt Becker
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/