Hi!
I am trying to work with some panel data and am having some issues getting it into the format I would like. The data currently looks like:
state_id,state,transportation_type,date21927,date2 1928,date21929
1,Alabama,driving,100,102.9,103.51
1,Alabama,walking,100,99.93,100.28
1,Alabama,transit,100,105.66,105.66
2,Alaska,driving,100,104.69,104.64
2,Alaska,walking,100,100.7,99.12
2,Alaska,transit,100,87.49,84.6
Note that: dateXXXXX is an index of Apple Maps usage for a particular type of transportation (driving, walking, transit) on a particular day.
and I want it to look like: (I can do the transformation by hand, but the dataset is large and doing it by hand isn't feasible)
state_id,state,day,driving,walking,transit
1,Alabama,21927,100,100,100
1,Alabama,21928,102.9,99.93,105.66
1,Alabama,21929,103.51,100.28,105.66
2,Alaska,21927,100,100,100
2,Alaska,21928,104.69,100.7,87.49
2,Alaska,21929,104.64,99.12,84.6
I have used reshape long date, i(state_id transportation_type) j(day), but this gives me 3 observations per state (each observation has the transportation_type and the transportation index for a particular day, so with 3 types of transportation, there are 3 observations per state per day).
reshape long date, i(state_id) j(day) does not work because state_id is not unique to each observation
If anyone could help me out with this, I would appreciate it!
-William Hickman
I am trying to work with some panel data and am having some issues getting it into the format I would like. The data currently looks like:
state_id,state,transportation_type,date21927,date2 1928,date21929
1,Alabama,driving,100,102.9,103.51
1,Alabama,walking,100,99.93,100.28
1,Alabama,transit,100,105.66,105.66
2,Alaska,driving,100,104.69,104.64
2,Alaska,walking,100,100.7,99.12
2,Alaska,transit,100,87.49,84.6
Note that: dateXXXXX is an index of Apple Maps usage for a particular type of transportation (driving, walking, transit) on a particular day.
and I want it to look like: (I can do the transformation by hand, but the dataset is large and doing it by hand isn't feasible)
state_id,state,day,driving,walking,transit
1,Alabama,21927,100,100,100
1,Alabama,21928,102.9,99.93,105.66
1,Alabama,21929,103.51,100.28,105.66
2,Alaska,21927,100,100,100
2,Alaska,21928,104.69,100.7,87.49
2,Alaska,21929,104.64,99.12,84.6
I have used reshape long date, i(state_id transportation_type) j(day), but this gives me 3 observations per state (each observation has the transportation_type and the transportation index for a particular day, so with 3 types of transportation, there are 3 observations per state per day).
reshape long date, i(state_id) j(day) does not work because state_id is not unique to each observation
If anyone could help me out with this, I would appreciate it!
-William Hickman
Comment