This is a part of my data.
code:
input year str6 state value str6 type
2010 GA 1 A
2011 GA 2 A
2012 GA 3 A
2010 GA 4 B
2011 GA 5 B
2012 GA 6 B
2010 NY 7 A
2011 NY 8 A
2012 NY 9 A
2010 NY 10 B
2011 NY 11 B
2012 NY 12 B
2010 GA 1 A
2011 GA 2 A
2012 GA 3 A
2010 GA 4 B
2011 GA 5 B
2012 GA 6 B
2010 NY 7 A
2011 NY 8 A
2012 NY 9 A
2010 NY 10 B
2011 NY 11 B
2012 NY 12 B
year | state | value | type |
2010 | GA | 1 | A |
2011 | GA | 2 | A |
2012 | GA | 3 | A |
2010 | GA | 4 | B |
2011 | GA | 5 | B |
2012 | GA | 6 | B |
2010 | NY | 7 | A |
2011 | NY | 8 | A |
2012 | NY | 9 | A |
2010 | NY | 10 | B |
2011 | NY | 11 | B |
2012 | NY | 12 | B |
I want to convert my data like this:
year | state | value_A | value_B |
2010 | GA | 1 | 4 |
2011 | GA | 2 | 5 |
2012 | GA | 3 | 6 |
2010 | NY | 7 | 10 |
2011 | NY | 8 | 11 |
2012 | NY | 9 | 12 |
0 Response to reshape data long to wide with several IDs
Post a Comment