Bookmark and Share

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]

Aw: st: RE: Manipulating data in the time series dimension of unbalanced panels


From   [email protected]
To   [email protected]
Subject   Aw: st: RE: Manipulating data in the time series dimension of unbalanced panels
Date   Fri, 23 Aug 2013 18:51:07 +0200 (CEST)

Thanks, Joe. This is a longer but equally good way to code this.
 
Best, Kurt
 
 
 
 
 

Gesendet: Freitag, 23. August 2013 um 18:29 Uhr
Von: "Joe Canner" <[email protected]>
An: "[email protected]" <[email protected]>
Betreff: st: RE: Manipulating data in the time series dimension of unbalanced panels
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.stata.com/support/faqs/resources/statalist-faq/]
* http://www.ats.ucla.edu/stat/stata/[http://www.ats.ucla.edu/stat/stata/]

*
* For searches and help try:
* http://www.stata.com/help.cgi?search[http://www.stata.com/help.cgi?search]
* http://www.stata.com/support/faqs/resources/statalist-faq/[http://www.stata.com/support/faqs/resources/statalist-faq/]
* http://www.ats.ucla.edu/stat/stata/[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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index