Announcement

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

  • Help with Reshape please.

    Dear friends,

    Please help me with the following reshape; I think have a problem of invalid var names (including dots).

    I have the following data:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str20 seriescode str16(yr1993 yr1994)
    "DC.DAC.TOTL.CD" "95760000.2288819" "240929997.684434"
    "DT.ODA.OATL.KD" ".."               ".."              
    end
    A wide data where the first var is the list of vars, and the next are years.

    I wish to reshape to the following:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float year str20(DC_DAC_TOTAL_CD DT_ODA_OATL_KD)
    1993 "95760000.2288819" ".."
    1994 "240929997.684434" ".."
    end
    Where the first var is year, and then each one is a var.

    EDIT: solved:
    Code:
    replace seriescode = subinstr(seriescode, ".", "_",.)
    reshape long yr, i(seriescode) j(year)
    reshape wide yr, i(year) j(seriescode) string
    rename yr* *
    Thanks!
    Last edited by Gal Rakover; 21 May 2022, 08:54.
Working...
X