I have a dataset that looks like the following:
FIPS Year jan feb mar apr may jun jul aug sep oct nov dec
1001 2000 10 20 30 40 50 60 30 30 20 30 40 50
1001 2001 10 20 30 40 50 60 30 30 20 30 40 50
1003 2000 10 20 30 40 50 60 30 30 20 30 40 50
1003 2001 10 20 30 40 50 60 30 30 20 30 40 50
Previously, the data had FIPS in one column and then month-year in each other column. I reshaped it into the current format using reshape long. I am trying to reshape the data so that there is both a year and month column so that each row is a year-month combination for a specific FIPS code. I used the following code:
foreach var in jan feb mar apr may jun jul aug sep oct dec nov {
rename `var' v_`var'
reshape long v_, i(fips year) j(time)
However, I received the following error:
variable time contains all missing values
Then, I tried:
variable year already exists
and got the error:
variable year already exists
Data are already long.
How I can reuse the reshape long code to get it into the desired format?