Announcement

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

  • Error; repeated time values in sample

    Hi,
    I want to do an time series analysis. i use the comand tsset to tell stata that the data are time series. When doing so i got the error meassage "repeated time values in sample".
    I understand what the problem is, but would be very thankful if some one could help me solve the problem.

    Click image for larger version

Name:	Screen dump data.PNG
Views:	1
Size:	52.9 KB
ID:	1367646



    Best regards,
    Gregg
    Last edited by Gregg orian; 13 Dec 2016, 10:11.

  • #2
    Well, the data are clearly not a time series. It looks as if you have panel data. As best I can tell from what you show, you have quarterly observations on a group of countries (one observation on each quarterly date, per country. So you need to use -xtset-. Now, you can't use country as the panel variable because it is a string. So I would do this as:

    Code:
    encode country, gen(ncountry)
    xtset ncountry date
    That will enable to use panel data estimators, and time series operators like lag and lead.* You will not, however, be able to use commands that strictly require time series data, as that is not what you have.

    In the future, please post example data using the -dataex- command. A screen shot is not helpful if it is necessary to replicate your data to try out code on it. There is no reasonable way to import a screenshot into Stata. The -dataex- command makes it possible for those who want to help you to easily create a faithful replica of your data using a simple copy/paste operation. You can install -dataex- by running -ssc install dataex-. The instructions for use are in -help dataex-.

    Added: *Actually, if your data really are one observation per quarter and if you want to use lag and lead operators to refer to the preceding and following quarter, respectively, then you need to do a bit more:

    Code:
    gen int qdate = qofd(date)
    format qdate %tq
    xtset ncountry qdate
    If you use date rather than qdate in your -xtset-, then Stata will interpret the lag of a given date to be the immediately preceding day, rather than the immediately preceding quarter. Using qdate overcomes this.
    Last edited by Clyde Schechter; 13 Dec 2016, 10:20.

    Comment


    • #3
      Thank you for the help

      Best regards
      Gregg

      Comment

      Working...
      X