Announcement

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

  • Panel graph flightdata

    I'm using flightdata from origin to destination per year and quarter. I want to make a graph giving the departure frequency per quarter from a specific airport.
    I tried this first:
    xtset departures_performed year
    but stata gives --> repeated time values within panel

    Does someone know how to create a graph?

  • #2
    Welcome to Statalist.

    If you have one variable with the year and another variable with the quarter, then your date information is not suitable for many uses in Stata, and you should combine those into a single variable giving a Stata Internal Format quarterly date.

    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.

    Once you review that information, you will need to do something like the following.
    Code:
    generate qdate = yq(year, quarter)
    format qdate %yq
    graph bar (sum) departures_performed if origin=="ZRH", over(qdate)
    where the graph bar command I show is intended to show total departures from the Zurich airport to all destinations, by quarter.

    Comment


    • #3
      Thank you for your response. I first have to change the variable dest given per airport code --> to frequencies from origin to the number of destinations the airlines fly to per year quarter. I was thinking about using egen or the collapse function.

      Comment


      • #4
        I'm afraid I cannot imagine how your data are structured, or more accurately, I can imagine many ways it may be structured 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.

        Be sure to use the dataex command to do this. If you are running version 15.1 or a fully updated version 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.

        When asking for help with code, always show example data. When showing example data, always use dataex.

        Comment


        • #5
          The question in post #3 has been reposted in a new topic at

          https://www.statalist.org/forums/for...t-airline-data

          Comment

          Working...
          X