Good morning, I have j individuals in a single year, each working at n companies. The companies are deployed horizontally and the variables follow the same order for each company.
Here is an example of the dataset I have:
where:
id: person id
comp_id: company id
comp_roa: company n's roa
comp_roe: company n's roe
comp_name: company n's name
Please note that each variable is chanracterized by a number indicating the n company the individual works at.
I would like to stack the companies' variables "vertically" and to do this for every individual.
Ideally, starting from the table above, I would like to get something as follows:
How can I go with this? Can you please provide any assistance on this matter?
I would greatly appreciate.
Thank you!
Here is an example of the dataset I have:
id | comp1_id | comp1_roa | comp1_roe | comp1_name | comp2_id | comp2_roa | comp2_roe | comp2_name | comp3_id | comp3_roa | comp3_roe | comp3_name |
1 | 11501 | 0.60 | 0.30 | Ealza | 28282 | 0.12 | 0.10 | Thasleof | ||||
2 | 83910 | 0.50 | 0.20 | Werdar | 48402 | 0.32 | 0.12 | Cascan | ||||
3 | 10485 | 0.40 | 0.40 | Aldea | 29101 | 0.19 | 0.05 | Raham | ||||
4 | 93759 | 0.60 | 0.10 | Clapa | 19323 | 0.28 | 0.25 | Rongifu | 82739 | 0.32 | 0.12 | Burgam |
where:
id: person id
comp_id: company id
comp_roa: company n's roa
comp_roe: company n's roe
comp_name: company n's name
Please note that each variable is chanracterized by a number indicating the n company the individual works at.
I would like to stack the companies' variables "vertically" and to do this for every individual.
Ideally, starting from the table above, I would like to get something as follows:
id | comp_id | comp_roa | comp_roe | comp_name |
1 | 11501 | 0.60 | 0.30 | Ealza |
1 | 28282 | 0.12 | 0.10 | Thasleof |
2 | 83910 | 0.50 | 0.20 | Werdar |
2 | 48402 | 0.32 | 0.12 | Cascan |
3 | 10485 | 0.40 | 0.40 | Aldea |
3 | 29101 | 0.19 | 0.05 | Raham |
4 | 93759 | 0.60 | 0.10 | Clapa |
4 | 19323 | 0.28 | 0.25 | Rongifu |
4 | 82739 | 0.32 | 0.12 | Burgam |
How can I go with this? Can you please provide any assistance on this matter?
I would greatly appreciate.
Thank you!
Comment