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]

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


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Manipulating data in the time series dimension of unbalanced panels
Date   Fri, 23 Aug 2013 17:38:25 +0100

bysort Country (time) : gen Dummy2 = sum(Dummy1) >= 1

See also http://www.stata.com/support/faqs/data-management/first-and-last-occurrences/
Nick
[email protected]


On 23 August 2013 17:17,  <[email protected]> wrote:
> 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/


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