Announcement

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

  • Transpose between row and column

    Hi all,
    I know there are lots of posts about transpose, but I still find troubles with my table. I have a large table as below




    Then I would like the table become as below





    I have tried reshape command, but can not find it correct. Could you please help?
    Thank you so much.
    Attached Files
    Last edited by Nguyen Phuong; 05 Oct 2021, 19:47.

  • #2
    Try:
    Code:
    h xpose
    http://publicationslist.org/eric.melse

    Comment


    • #3
      xpose is an old command that is rarely what you need. It doesn't work well with data that include both numeric and string variables: in fact the whole idea that variables can be transposed works well only if all variables are numeric OR all variables are string.

      Think of it this way: the implication that after transposing some observations are all numeric while other observations are all string really doesn't match Stata's data model (or any other?).

      I am bemused at why you think transposing is needed or even would be helpful here.

      There is a problem evident in the screenshot: it seems that you've imported some variables with numeric content as string. One obvious reason is that Stata could not make sense of
      NA as a missing value code.

      Code:
      destring *, ignore("NA") replace 
      should help there. Otherwise reshape long seems indicated. There is no data example here, but I would guess at.


      Code:
      ds date, not
      rename (`r(varlist)') (price=)
      reshape long price, i(date) j(code) string
      Last edited by Nick Cox; 06 Oct 2021, 03:04.

      Comment


      • #4
        Thank you. That helps my mind alot. I am changing from SAS to stata. This tabel will be just one colume when I finish to connect it to the others. Let me try the code. Thank you so much.

        Comment

        Working...
        X