Hi. I am trying to reshape a panel of US county population data organised by county and year (data post below)
(fips) is the unique county indicator, (year) is the year indicator and each fips/year has 19 age categories (agegroup).
The seven population variables are currenntly orgaised as: total (tot_pop), total male (tot_male), total females (tot_female)...etc.
What I would like is one observation per fips/year for each combination of age-braket/population-variables. So a total of 133 variables.
i.e. population aged 85+ (a_85_tot_pop),female white population aged 75-80 (a_75_80_wa_female), etc.
I am confused about how to use the reshape commands to achieve this task as it seems l likely have to take my data to wide view, and then back to long view but not sure where to begin here.
In reshape command: i(varname) would include fips s_id c_id year. I'm not sure how to go about identifying the j(varname). (agegroup) is currently string data, while (agegrp) is a numerical indicator for (agegroup)
fips | s_id | c_id | year | agegrp | agegroup | tot_pop | tot_male | tot_female | wa_male | wa_female | ba_male | ba_female |
2180 | 2 | 180 | 2000 | 17 | 80-84 | 58 | 27 | 31 | 3 | 4 | 0 | 0 |
2180 | 2 | 180 | 2001 | 17 | 80-84 | 58 | 27 | 31 | 3 | 4 | 0 | 0 |
32027 | 32 | 27 | 2002 | 18 | 85+ | 58 | 24 | 34 | 24 | 34 | 0 | 0 |
2185 | 2 | 185 | 2003 | 16 | 75-80 | 58 | 18 | 40 | 0 | 2 | 0 | 0 |
Thanks,
Mike
0 Response to Reshaping long data with mtultiple categories into long data
Post a Comment