Announcement

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

  • Reshaping time series data into panel format

    Hi,

    I would like some help on reshaping time series data in panel format, where the time series data relates to the return index on bank's stocks, obtained from Datastream. I have studied the help guide on the reshape command but still cannot figure out how to do this. I am assuming I have to use ''reshape long'', but I am not sure if the way my data is organized now allows me to use this command to obtain the desired result. In the attached file you can find a screenshot from the browse window in stata which gives a good idea of how my dataset looks like. The return index is obtained for 71 banks on a daily basis for the period 2008-2014. Any help on how I can reshape this data into panel format would be much appreciated.

    Thanks in advance,

    Ali
    Attached Files

  • #2
    Welcome to Statalist.

    Something like the following untested code may do what you need on the data you picture; you will have to adjust the rename command to include all 71 banks.
    Code:
    rename (ASUNX-BAABC) (retindx=)
    rehape long retindx, i(time) j(bank) string
    With that said, to improve your future posts, please first 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. Note especially sections 9-12 on how to best pose your question.

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

    In particular, screenshots are a poor presentation of data and the FAQ requests you not use them for that purpose. With usable sample data I could have tested the code i suggested.

    Please be sure to use the dataex command to show example data. 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 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


    • #3
      Please read the FAQ for excellent advice on how to post data examples in this Forum. In #12 you will learn that screen shots are deprecated for a number of reasons. In your instance, the screenshot you posted is unreadable, at least on my computer. Even if it were readable, screenshots cannot be imported into Stata to test code.

      Please post back, using the -dataex- command to show your example data. 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, which in turn makes it more likely that their answer will actually work in your data.

      Added: Crossed with #2. Evidently your screenshot was readable on William Lisowski's computer.

      Comment

      Working...
      X