Announcement

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

  • Panel data set

    In my research I have monthly data from June 2006 to July 2016 for two different countries.I start by creating a country code to give a number to each country then I move to create my time variables. The issue is that when I tell Stata that my data is panel data using xtset Stata changes automatically the order of my time variables. basically 2006 goes at the bottom while 2010 is at the top. The issue is that I need them to be in order because I am going to use Difference in difference; therefore I'll need to create a time dummy later one. I cannot understand what is wrong with it... thank you very much in advance
    This is the code I use
    xtset countrynum date, monthly

  • #2
    I'm not certain I understand your problem. You'll get better advice if you provide a sample of your data with the -dataex- command (see the FAQ, especially section 12.2 https://www.statalist.org/forums/help#stata. However, you can always re-sort your data:

    Code:
    sort countrynum date
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      I expect that the sample of your data requested by Carole will show that you have created your date variable incorrectly.

      Stata's "date and time" variables are complicated and there is a lot to learn. If you have not already read the very detailed Chapter 24 (Working with dates and times) of the Stata User's Guide PDF, do so now. If you have, it's time for a refresher. After that, the help datetime documentation will usually be enough to point the way. You can't remember everything; even the most experienced users end up referring to the help datetime documentation or back to the manual for details. But at least you will get a good understanding of the basics and the underlying principles. An investment of time that will be amply repaid.

      All Stata manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu.

      With that said, then, the problem is not with your xtset command, but with the code you used to create your date variable. Along with the sample of your data, you should post the code you used to create the date variable. In posting code, do follow the advice in the section of the FAQ that Carole linked to, and surround your code with CODE delimiters to ensure it is readable.

      Comment

      Working...
      X