Announcement

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

  • Error in xtset panel data (How can I define my dataset as panel data in stata?)

    I have the following panel dataset which is annual data. I start with using xtset command as follows:

    xtset Years, yearly

    But I see the following error

    repeated time values in sample

    How can I define my dataset as panel data in stata in order to apply Probit model?

    Thank you.
    Click image for larger version

Name:	Screen Shot 2022-07-08 at 12.05.25 PM.png
Views:	2
Size:	160.3 KB
ID:	1672716


  • #2
    Using Statalist is just like making wild mushroom risotto. If I asked you to make my favorite version of risotto, you'd likely need to know what the SPECIFIC ingredients are and the steps you do to make said dish. So far you've given neither, you're asking us for help to make a dish, and you've not given the recipe (the code you've tried) or the raw ingredients (the data).
    Precisely, you must give your dataset (or an equivalent toy example), either by using dataex or importing the real data from a public link (as I do here). In addition, you must give the your code that you've tried (formatted properly). No dataset, no code=no real assistance.

    Please do not use screenshots (ever) to show your data. There's a straightforward solution here, most likely, but you have to show your data properly first.

    Comment


    • #3
      Elaborating on Jared's discussion.

      Descriptions of data are well-meant but insufficient to help those who want to help you. Even the best descriptions of data are no substitute for an actual example of the data. There are many ways your data might be organized that are consistent with your description, and each would require a somewhat different approach. In order to get a helpful response, you need to show some example data. And that example data must be the Stata dataset resulting from importing the pictured Excel spreadsheet into Stata, so we can distinguish between data problems resulting from inappropriate importing and data problems inherent in your dataset.

      Be sure to use the dataex command to do this. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, dataex is already part of your official Stata installation. If not, run ssc install dataex to get it. Either way, run help dataex and read the simple instructions for using it. dataex will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

      With that said, you should review the output of
      Code:
      help xtset
      and, if you don't understand the difference between the "panel variable" and the "time variable", and in general how to structure panel data in Stata, in
      Code:
      help xt
      click on the "Remarks and Examples" links to open the Stata Longitudinal Data/Panel Data Reference Manual PDF included in your Stata installation and review that section of the Introduction to xt commands.

      Comment


      • #4
        Sean:
        as an aside to previous excellent advice, the way you -xtset- your data i simply wrong.
        In all likelihood, you need something like:
        Code:
        xtset Country Year
        with the proviso that both variables should be in numeric format.

        If Stata throws the r(451) message -repeated time values within panel-, you can -xtset- your dataset with -panelid- only, provided that you do not plan to use time-series operators, such as lags and leads.

        As a closing-out unsolicited advice, you may want to increase your knowledge of panel data regression via one of the panel data econometrics textbooks reported in the reference section of the -xtreg- entry, Stata .pdf manual.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X