Announcement

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

  • Duplicating observations around event dates

    Hi,

    I have panel data and I am utilizing an event study approach. The problem is that some event windows are very close to each other and will overlap. For example, an event may happen for company X on Jan 1 and again on Jan 3. The event day for Jan 1 will thus be both 0 (time of event) and -2 (days before event), while it will be both 0 for Jan 3 and +2 (days after an event). If I want to look at 120 days before the event and 30 days after the event this becomes a problem as one row (observation) cannot have two event days.

    I am thinking this can be solved by making an id variable for all the events, separating them, and then using the duplicate command with an if statement but I am struggling with it and not very used to the duplicate command.

    Thanks in advance!

  • #2
    Note that it is not a problem with the method in my study that the events will overlap, as it normally is. I only need help with the Stata code to separate/duplicate the observations.

    Comment


    • #3
      Hello Klas,
      Note this is the Mata section, to discuss Stata's matrix programing language.
      Your issue doesn't seem to be related with Mata, so please consider re-posting it in the general section. Moreover you'd increase your chances to get replied.
      Concerning your problem, it is not very clear what you want to do (or I am not sure that duplicating the events is the good solution, you could also create several event variables for one date to have both 0 and +2 value).
      Anyway, to do what you want to, you should rather use the expand command than the duplicates one.
      You just have to know how many "events" happen for each company.
      Code:
      bysort company : expand nb_event
      See help expand for further details.
      Best,
      Charlie

      Comment

      Working...
      X