I need to move data in columns into rows. (moving the b1 and b2 columns below into a1 and a2 but as a new case, similar to what is done with reshape.)
Beginning table:
Desired table:
I have tried to use reshape and xpose, but can't get it to do what I want. Any advice? I feel I am close but don't even know the proper terminology to type.
Beginning table:
id | a1 | a2 | b1 | b2 |
1 | 1 | 2 | 3 | 4 |
2 | 5 | 6 | 7 | 8 |
3 | 9 | 10 | 11 | 12 |
4 | 13 | 14 | 15 | 16 |
5 | 17 | 18 | 19 | 20 |
Desired table:
id | Case | a1 | a2 |
1 | 1 | 1 | 2 |
1 | 2 | 3 | 4 |
2 | 1 | 5 | 6 |
2 | 2 | 7 | 8 |
3 | 1 | 9 | 10 |
3 | 2 | 11 | 12 |
4 | 1 | 13 | 14 |
4 | 2 | 15 | 16 |
5 | 1 | 17 | 18 |
5 | 2 | 19 | 20 |
Comment