This question already has an answer here:
- How to reshape data from long to wide format? 9 answers
I have data that comes out of a DB in a normalized way with a field for year, state, and value.
I would like to do analysis on the data and need it formatted where each year is a field and not a record.So I would like the data where each record is a state and then there's a field for each year and each value for those fields are the value for that year and that state.
Is there a command for doing this?
So I have:
State Year Value
KY 1998 56
KY 1997 78
IL 1998 48
IL 1997 72
and I want:
State 1997_value 1998_value
KY 78 56
IL 72 48