https://www.stata.com/statalist/arch.../msg00506.html
Here is a minimum working example:
Code:
clear input ID SD_C1_01_2017 SD_C1_02_2017 SD_C1_01_2018 SD_C1_02_2018 1 50 85 30 40 2 30 0 0 40 3 10 20 0 0 end * Put all the needed future in a local macro unab stublist: SD_C1* * Cut out the year (e.g. _2007) at the end to obtain the actual stubs foreach v of local stublist { local stubs `"`stubs' `= substr("`v'",1,length("`v'")-4)'"' } * Reshape automatically (does not work) reshape long `stubs' , i(ID) j(Year) * Reshape manually (works) reshape long SD_C1_01_ SD_C1_02_ , i(ID) j(Year)
0 Response to Reshape long with local for many stubs does not work
Post a Comment