Announcement

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

  • Repeated time values within panel

    Dear statalisters,
    I am working in a new database and when I code
    Code:
    xtset firm year
    I received a message saying
    repeated time values within panel
    .
    I realise that means that I have a second variable measuring time, but I don`t have any.
    Could you help me please to recognize the problem and solve it?

    Thank you for your advice,

    Alejandro

  • #2
    I realise that means that I have a second variable measuring time, but I don`t have any.
    No, that's not what it means. It means that you have some combination of firm and year that appears more than once in your data. To find the offending observation(s) you can do this:

    Code:
    duplicates tag firm year, gen(flag)
    browse if flag
    and you will see where the problem is coming from.

    As for solving the problem, that will depend on what you see. It may be that you are mistaken in your belief that you have yearly panel data: maybe the data is quarterly or monthly or some finer time interval. In that case using the appropriate time variable, rather than year, in your -xtset- will resolve the problem.

    Or it may be that your data set contains some completely redundant observations: this often happens in data management when data are pulled together from different sources--sometimes the same information is in multiple sources and ends up in the data set multiple times. In that case -duplicates drop- will eliminate the redundancies and then you can proceed as you originally planned. (Except that the occurrence of these redundant observations suggests that the data management that created the data set was not all that thorough, and when there is one mistake others may also lurk. So in this case, before proceeding, I would carefully review how this data set was created in the first place and think hard about whether it can be trusted.)

    Or it may be that you have two or more observations for the same firm in the same year and they disagree on other variables. Now you have a more serious problem because you have to figure out how to resolve those disagreements. There is no generic solution to this problem: it obviously depends on exactly where this data comes from and how it was put together and understanding why the observations disagree on what "should be the same thing."

    Another possibility is that you really don't have panel data at all. You just have a lot of data about firms in different years, but it isn't necessarily supposed to be exactly one observation per year. In that case, the solution is to not specify a time variable in your -xtset- command. You just -xtset firm-. -xtset- does not require a time variable. However, in this situation, where there are multiple valid observations on the same firm in a given year, there is no longer any meaning to things like lags and leads, or autoregressive correlation structure. Consequently, while most Stata commands will work normally, any attempt to use time-series operators or autoregressive structures will produce error messages.

    Comment


    • #3
      Dear Clyde,

      Its good to read you again. About what you said, you are right, I ran the code and I found 30 obs flagged. After that, I wrote duplicates drop and 7 observation are deleted (don't know why only 7).
      Now, there are still 16 observations flagged (of a total of 22591 observations) after repeating the same process, but when I write the code for deleting duplicates,
      it say
      Duplicates in terms of all variables
      and then
      (0 observations are duplicates
      but there is still 16 observations that seems duplicated.
      what else should I do?
      Thank you Clyde,

      Alejandro

      Comment


      • #4
        Dear Clyde, I just deleted the 8 duplicates by hand and was all solved.
        Thank you very much for your advice.
        Alejandro

        Comment

        Working...
        X