Announcement

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

  • How to drop repeated years in a panel dataset

    Hi everyone,

    I have a panel dataset with countries and years from 1999 to 2019. However, for each country there are some repeated years. For example, Bolivia has 2002 recorded 4 times. How do I drop the repeated years for each country while keeping the first occurrence? Meaning that I want 2002 to appear once in Bolivia, and the same for other repeated years for other countries.

    Many thanks,
    Yasmine

  • #2
    h duplicates

    Comment


    • #3
      The advice in #2 will solve your immediate problem.

      BUT, why do you have these duplicate observations in the first place? Most often, this indicates a problem in the data management that created the data set you are working with. And where there is one error, others may lurk as yet unnoticed. So before proceeding, you should thoroughly review all of the code that created this data set and fix whatever errors you find, including the one(s) that led to the duplicate observations. If the data set was not created in your shop, you should take the matter up with whoever did create it.

      Comment


      • #4
        Related to your post at https://www.statalist.org/forums/for...lict-ucdp-prio, duplicates of country and year indicate the existence of more than one conflict in a country and year. If you follow my code in #3, as you are interested in the presence of a conflict in a given country and year, the following line deals with duplicates:

        Code:
        gen CIV=1
        contract country year CIV
        Last edited by Andrew Musau; 24 Apr 2022, 23:50.

        Comment

        Working...
        X