Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reshape data

    Hi all, I have used this program to reshape data successfully many times.
    insheet using ${DIR}/test_data.csv

    drop if country_name==""

    gen id = _n
    reshape long yr, i(id) j(year)
    encode indicator, gen(varnum)
    label save varnum using vardesc, replace
    drop id indicator
    rename yr data
    sort country_name year
    egen id=group(country_name year)
    reshape wide data, i(id) j(varnum)
    rename data1 test1


    Now, I get the following error

    file vardesc.do could not be opened


    The original data is in this format
    country_name Indicator yr1985 yr1986 yr1987
    Afghanistan test1 58 36 36
    Albania test1 3 2 5

    I am trying to get it into the format

    year country_name media
    1985 Afghanistan 58
    1986 Afghanistan 36
    1987 Afghanistan 36
    1985 Albania 3
    1986 Albania 2
    1987 Albania 5
    This usually works with no problem at all. Any thoughts on how I might update the program? I am using STATA 12 SE .

    Thanks,
    Steve
Working...
X