Announcement

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

  • Stack/Reshape 12 columns into one, not on top eachother but one from each column

    Okey so I have two portfolios numbered 1 and 10, with monthly returns tr1 to tr12. I'd like to reshape the data so I have "year deciles month return". Any ideas?



    Click image for larger version

Name:	Data.png
Views:	2
Size:	407.9 KB
ID:	1442972
    Attached Files

  • #2
    Something like this might do. I can't test it because my copy of Stata lacks an import png command.
    Code:
    reshape long tr, i(year deciles) j(month)
    rename tr return
    For better answers to future questions, 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. In particular, please read FAQ #12 and help those whose help you seek by posting example data using the dataex command. If you are running Stata 15.1 or later, it is already installed. For earlier versions of Stata, install dataex by typing ssc install dataex. Type help dataex to read the simple instructions for using it. Using dataex will enable those who want to help you to quickly and easily create a 100% faithful replica of your situation to test their ideas and code on.

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

    Comment

    Working...
    X