Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making a dummyvariable in a time series where at any point in time it has taken a value

    Hey guys,

    We have a dataset with observations ranging between years 2006 and 2015. This is observations from different firms with observations for each of the mentioned years. We have a dummy variable ranging between 2011 and 2015 of values 1 and 0. We want to make a new dummy variable that is equal to 1 for all observations for all years if the previously mentioned variable has taken a value of 1 after 2011 at any point in time and zero otherwise.

    Any suggestions? Inputs are much appreciated.

  • #2

    Code:
    egen newdummy = total(dummy * (time > 2011)), by(firmid) 
    replace newdummy = newdummy > 0
    "after 2011" is here interpreted as > 2011.

    If you really meant "in or after 2011" use >= instead.

    "for all observations for all years " presumably means also "for each firm", not what it says.

    Comment

    Working...
    X