Announcement

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

  • Stacking 5 columns under 5 other columns, 200 times

    I have a dataset with the following structure:
    year Company 1 data A Company 1 data B Company 1 data C Company 2 data A Company 2 data B Company 2 data C Company 3 data A Company 3 data B ...
    1
    2
    3
    ...
    I have around 1,000 different companies, each with 5 data points (3 in this simplified example).
    I would like to make this a panel structure, as follows:
    year company Data A Data B Data C
    1 1
    2 1
    3 1
    1 2
    2 2
    3 2
    1 3
    ...
    I am aware of the reshape command. However, I do not see how I can use it in this context - if it is usable after all. In essence, I feel like I would neet to 'cut' the observations of each company and 'paste' them under those of the first, while creating a new variable that indicates which company is inserted, and repeating the 'year' values.

    Many thanks for any potential help.

  • #2
    For this kind of thing the devil is in the detail. So can you use dataex to give us an example of what your data looks like?

    As a preview to the final answer: Yes, your problems sounds like it is exactly what reshape is for.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten Buis This is the dataset in question.

      Comment

      Working...
      X