Hi everyone.
I would like to reshape my data from wide to long, but over two dimension, one of which is a standard one-time dimension.
i have the data that have the format:
Dataset1
The last four digit of these "x" variables correspond to year, while "hr+3 digit number" within these "x" variables corresponds to another dimension. I want my dataset to looks like this
Dataset2
To conclude, I want to have X variable varying over id (as it already does) and two new variables - "year" and "Y".
The command
seem to work only with year dimension (converts data from wide to long, using "year" identifies only). I always get an error when I try applying it.
Does anyone know how I can get Dataset2 from Dataset1 using "reshape" or any other state command?
Thanks in advance!
I would like to reshape my data from wide to long, but over two dimension, one of which is a standard one-time dimension.
i have the data that have the format:
Dataset1
Code:
----------------------- copy starting from the next line ----------------------------------------- copy up to and including the previous line ------------------Code:* Example generated by -dataex-. To install: ssc install dataex clear input byte id float(x_hr047_2006 x_hr048_2006 x_hr047_2007 x_hr048_2007) 1 .16038707 .0000384255 .03993386 .000923258 2 .3477554 .0000822979 .05899953 .001369665 3 .001378539 .004831353 .009549395 .005290506 4 .21207225 .0000128496 .04594259 .01215579 5 .003936227 .000480553 .010989835 .005820832 end
Dataset2
Code:
----------------------- copy starting from the next line ----------------------------------------- copy up to and including the previous line ------------------ Listed 8 out of 8 observationsCode:* Example generated by -dataex-. To install: ssc install dataex clear input byte id int year str5 y float x 1 2006 "HR047" .16038707 1 2007 "HR047" .03993386 2 2006 "HR047" .3477554 2 2007 "HR047" .05899953 1 2006 "HR048" .0000384255 1 2007 "HR048" .000923258 2 2006 "HR048" .0000822979 2 2007 "HR048" .001369665 ... end
The command
reshape long
Does anyone know how I can get Dataset2 from Dataset1 using "reshape" or any other state command?
Thanks in advance!
Comment