Announcement

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

  • Condense data

    I have a panel dataset with an unequal number of observations per company. In other words, some companies might show up in the data five times and others might show up 11 times. I have 11 years total. Here is a sample of what I have:

    Company rank13 rank 12 rank11 rank10
    A 1 . . .
    A . 1 . .
    B . . . 2

    I would like to create one observation for each company with all ranks. For example:

    Company rank13 rank12 rank11 rank10
    A 1 2 . .
    B . . . 2

    I have tried to do this with the -reshape- command, but I can't get it to do what I want. I have also searched Google and Statalist, but haven't been able to find anything that applies.

    Thank you advance for your help.

  • #2
    I feel like some key info is missing. Is there a year variable? Can you only have a value once on a rank variable and in every other year you have to be missing on every rank variable? Maybe this is really a collapse problem, where you take the first/ only non missing value for each variable for each case.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      The -collapse- command was exactly what I was looking for. It worked perfectly. Thank you for your help.

      Comment


      • #4
        Great. In your example, after you collapse to one observation per company, I don't know why you would expect the 2 value for company A. Was that a mistake or am I missing something?
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Ahh, yes, that was a typo. It should have been a 1. Sorry about that.

          Comment

          Working...
          X