Announcement

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

  • Economic student that needs some help with date and year with panel data

    Hi everyone and happy thanksgiving!

    Its probably simple stuff but I'm having some difficulties so some help would be appreciated a lot! So im writing my thesis this semester and need some help with specifiying date and year in a panel data and first, I want to make a xline in a graph with a scatter setting. Been trying to use excels "jan2010", "feb2010", "mar2020" etc but been having difficulties with specifying to stata since it doesn't understand the code and just replies invalied argument.

    Thus I wounder is there any year and date variable that works with in stata so I can specify it in an graph with the command scatter?

    Secondly, Im using a Difference-in-Difference method in my thesis and as might expected I've been running into some problems using "jan2010" etc since stata, once again doesn't really understand what I mean.

    As an conclusion, I guess these question is just a single question about if there are any alternative way to make year-month specification work smoothly. Been reading some of the manuals by Stata but haven't been able to plug them in smoothly into the do.file.

    Sincerly,

    Kevin

  • #2
    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.

    Beyond that, your questions really aren't clear without more detail, or at a minimum it is too difficult to guess at a good answer from what you have shared. Please help us help you. Show example data. Show your code. Show us what Stata told you. The Statalist FAQ provides advice on effectively posing your questions, posting data, and sharing Stata output.

    Comment


    • #3
      Kevin:
      welcome to this forum.
      It would be great if Stata were able to understand our research needs (even from sloppy codes); unfortunately, it is the other way round: it's up to us to understand how Stata works so that it can help us.
      Kind regards,
      Carlo
      (Stata 18.0 SE)

      Comment


      • #4
        Thank you for the quick responses! Much appreciated! So I added a screenshot to this messeage but so the variable I'm wondering is about is "Monthyear" "jan2010" and etc are directly derived from excel but seems to not to work in STATA when I include the variables in for an example:

        scatter y monthyear, xline(jan2010)

        So im just woundering if there are similar substitutes.
        Attached Files

        Comment


        • #5
          The recommended reading on Stata date and time variables will explain what you need to know about how Stata handles dates and times. Do see the material on typing dates in to expressions.

          Perhaps
          Code:
          scatter y monthyear, xline(tm(2010jan))
          will do what you need with your data.

          Comment

          Working...
          X