Announcement

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

  • Repeated time values within panel r(451)

    i have panel data of firms. i have merged two data sets to process data further first i tired to declare it as panel. unfortunately, stata issued an error message. the code and error message is as:
    xtset gvkey year
    repeated time values within panel
    r(451);


    however, i have checked past posts. i also tried commands suggested in these post but none solved the problem. my data consists of 3698 firms, 30 variables, 69018 observations from year 1992 to 2016.
    my data set of gvkey and year is as:
    1004 1992
    1004 1993
    1004 1994
    1004 1995
    1004 1996
    1004 1997
    1004 1998
    1004 1999
    1004 2000
    1004 2001
    1004 2002
    1004 2003
    1004 2004
    1004 2005
    1004 2006
    1004 2007
    1004 2008
    1004 2009
    1004 2010
    1004 2011
    1004 2012
    1004 2013
    1004 2014
    1004 2015
    1004 2016
    1013 1992
    1013 1993
    1013 1994
    1013 1995
    1013 1996
    1013 1997
    1013 1998
    1013 1999
    1013 2000
    1013 2001
    1013 2002
    1013 2003
    1013 2004
    1013 2005
    1013 2006
    1013 2007
    1013 2008
    1013 2009
    1013 2010
    1034 1992
    1034 1993
    1034 1994
    1034 1995
    1034 1996
    1034 1997
    1034 1998
    1034 1999
    1034 2000
    1034 2001
    1034 2002
    1034 2003
    1034 2004
    1034 2005
    1034 2006
    1034 2007
    1045 1992
    1045 1993
    1045 1994
    1045 1995
    1045 1996
    1045 1997
    1045 1998
    1045 1999
    1045 2000
    1045 2001
    1045 2002
    1045 2003
    1045 2004
    1045 2005
    1045 2006
    1045 2007
    1045 2008
    1045 2009
    1045 2010
    1045 2011
    1045 2012
    1045 2013
    1045 2014
    1045 2015
    1045 2016
    1055 1992
    1055 1993
    1055 1994
    1055 1995
    1055 1996
    1056 1992
    1056 1993
    1056 1994
    1056 1995
    1056 1996
    1056 1997
    1056 1998
    1056 1999
    1056 2000
    1056 2001
    Last edited by Kiran Abro; 30 Jan 2019, 01:54.

  • #2
    Kiran:
    this is not an issue as long as you do not plan to use time-series commands such as lags and leads.
    Hence, you can -xtset- you data with the -panelid- only:
    Code:
    xtset gvkey
    Kind regards,
    Carlo
    (Stata 15.1 SE)

    Comment


    • #3
      Dear Carlo Thank you for being so co-operative and quick response. However, i am required to declare panel based on gvkey and year both. Luckily, i sorted out the problem,i checked for the duplicates and dropped duplicates. i am writing the command to help other stata users if they ever face the similar issue.

      sort gvkey year

      quietly by gvkey year : gen dup = cond(_N==1,0,_n)

      drop if dup>1
      (9090 observations deleted)
      xtset gvkey year
      panel variable: gvkey (unbalanced)
      time variable: year, 1992 to 2016, but with gaps
      delta: 1 unit

      Comment


      • #4
        You solved the problem by brute force. The deeper question is whether your duplicates are pure duplicates or you are arbitrarily dropping some observations and not others. The duplicates command offers a principled tool to investigate.

        Comment


        • #5
          Kiran:
          thanks for sharing your fix.
          PS: crossed in the cyberspace with Nick's reply, that focuses on the gist of the matter.
          Last edited by Carlo Lazzaro; 30 Jan 2019, 02:15.
          Kind regards,
          Carlo
          (Stata 15.1 SE)

          Comment


          • #6
            Dear Carlo Lazzaro sure.

            Comment

            Working...
            X