Announcement

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

  • transform time series data into a panel

    Hi,

    İs there an easy way to convert the following data on stock returns

    Country a Country b
    t return return
    t+1 return return
    t+2 return return
    t+3 return return

    into

    t Country a return
    t+1 Country a return
    t+2 Country a return
    t+3 Country a return
    t Country b return
    t+1 Country b return
    t+2 Country b return
    t+3 Country b return


    Thank you,
    Nazlı

  • #2
    Code:
    help reshape

    Comment


    • #3
      Your presentation is a little confusing because you seem to have four variables: Country, a, Country, b, but give values for only 3. And it isn't legal to have two variables with the same name. So I'm guessing that what you meant is three variables: time (which you didn't give a name), Country_a (blank spaces are not allowed within variable names), and Country_b. The values of the variables Country_a and Country_b are actually stock returns relating somehow to those countries in the given years. You didn't give a name to your time variable, but in a Stata data set it will have to have one. So let's just call it time.

      Code:
      rename Country_* return*
      reshape long return, i(time) j(Country) string
      will get you what you are looking for. (Well, it won't come out in the sort order you show, but you can just -sort Country time- to get that.

      More generally, the -reshape- command is one of Stata's most powerful and important commands. Time spent learning about it in the user's manuals will repay itself many fold, and quickly.

      Comment


      • #4
        thank you very much!

        Comment


        • #5
          Dear Clyde Schechter,

          I have a panel data of countries and years. I need to make it look like a time series. I want to get an id e.g. 11, 12 (first country first year, first country second year). Could you please help me get that in stata?

          Regards,

          Arshad

          Comment


          • #6
            Arshad: Please don't ask the same question twice in 2 minutes.

            Anyone interested in Arshad's question please follow http://www.statalist.org/forums/foru...-a-time-series

            Comment

            Working...
            X