Announcement

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

  • Turning Panel Data into Time Series

    Right now i have data with Variable labels Year, Country, AverageEloRating, AverageRank as panel data (so years are repeated throughout the data set for each individual country). However, I need to generate variables to be Year (without repeat), Afghanistan, Albania, Algeria, etc. with the 30 year timeframe, and each countries elorating listed below the individual country label.


    I have been playing around with the reshape command although unable to find a command to shape my data set this way. Does anyone no a way in which I could solve this problem?

    Thanks!

  • #2
    Welcome to Statalist.

    The short answer is that the reshape wide command is what you want. But without knowing more about your data, it's difficult to be more precise.

    If you need a more helpful response, you will be more likely to receive it if you provide a sample of your dataset with these variables. Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post, looking especially at sections 9-12 on how to best pose your question. It would be particularly helpful to post a small hand-made example, perhaps with just a few of your countries for a few years.

    In particular, please read FAQ #12 and use dataex when posting sample data to Statalist. If you are running Stata version 15.1, then dataex is part of your installation already. If running an earlier Stata, run ssc install dataex to get the command. Either way, run help dataex to read the simple instructions for using it. It takes just seconds to use dataex to provide a way for those who want to help you to create a complete and faithful replica of your example data in their own Stata. That, in turn, eliminates all sorts of questions that are left unanswered by descriptions or even by data listings and tables. And it enables people to test out code, so that you get the right answer the first time.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Added in edit: you should probably also give an explanation of why you want your data in the wide layout you describe. The experienced users here generally agree that, with few exceptions, Stata makes it much more straightforward to accomplish complex analyses using a long layout of your data rather than a wide layout of the same data.

    Comment


    • #3
      Suppose I were to ask you for specific driving instructions to 1 State Street, Chicago IL, USA but tell you only that I am starting out from somewhere in the United States. You would not be able to help me.

      Well, that is what you've done. You're asking for help with code but have given only a vague description of your data.

      If you want help with code, you must show an example of your data. Descriptions are almost always insufficient. And the only truly helpful way to show examples is by using the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to 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.

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

      Added: Crossed with #2.

      Comment

      Working...
      X