Announcement

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

  • Merging multiple observations per time in panel data.

    Dear all,

    I have a panel datatset of 74 countries with multiple daily observations. I have also four events A, B, C and D as dummy variables.

    Click image for larger version

Name:	example.png
Views:	1
Size:	30.7 KB
ID:	1677022


    As you can see from the Table, an event may occur multiple times per one date (ex: event A in 3/17/2020). Also, multiple events may occur in one time (e.g., event B, A and C in 3/19/2020).

    I would like to merge these multiple observations in order to have just one observation per date with all occuring events. For example, for 3/19/2020 event A, 1; event B, 1; event C, 1; event D, 0. For 3/17/2020, event A, 1; event B, 0; event C, 0; event D, 0

    Thank you in advance!
    Jon.

  • #2
    In Stata terms this calls for a collapse and not a merge in the sense of the merge command.

    I guess at

    Code:
    collapse (max) A B C D , by(country date)

    Comment


    • #3
      It works perfectly! thanks a lot.

      Comment

      Working...
      X