Hi All
I need some help & advice with using the reshape command:
I have a longitudinal dataset in the wide format. I've done considerable cleaning and housekeeping to prep my variables for analysis. I now need to reshape my dataset into long format for my analysis:
However, I didn't realise that reshape orders the variables numerically after running the command above, which has altered the ordering of the newly created j (wave) variable.
For example, the diab variable (which indicates if a subject has diabetes or not 0/1), was initially 5 variables: diab82 diab89 diab99 diab09 & diab15, where the suffix numbers indicate wave year (1982, 1989, 1999 and so on). After running reshape, Stata orders the 'wave' or j variable in ascending order of 9, 15, 82, 89, 99. Is there anyway to take care of this with the reshape command or do I need to rename all my variables?
example dataset (in wide format):
Thanks!
/Amal
I need some help & advice with using the reshape command:
I have a longitudinal dataset in the wide format. I've done considerable cleaning and housekeeping to prep my variables for analysis. I now need to reshape my dataset into long format for my analysis:
Code:
reshape long diab anaemia bmi, i(id) j(wave)
However, I didn't realise that reshape orders the variables numerically after running the command above, which has altered the ordering of the newly created j (wave) variable.
For example, the diab variable (which indicates if a subject has diabetes or not 0/1), was initially 5 variables: diab82 diab89 diab99 diab09 & diab15, where the suffix numbers indicate wave year (1982, 1989, 1999 and so on). After running reshape, Stata orders the 'wave' or j variable in ascending order of 9, 15, 82, 89, 99. Is there anyway to take care of this with the reshape command or do I need to rename all my variables?
example dataset (in wide format):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int id float(diab99 diab99f diab09 diab15 diab15f anaemia99 anaemia09 anaemia15 bmi82 bmi89 bmi99 bmi09 bmi15) 1 0 0 0 0 0 0 0 1 26.28196 27.85201 30.710836 27.91919 25.007694 2 0 0 0 0 0 0 0 0 28.37953 28.451317 28.066423 31.02016 29.96841 3 . . 0 0 0 . 0 . . . . . . 4 . . . 0 0 . . . . . . . . 5 0 0 0 0 0 0 0 0 25.03128 27.769075 29.470186 34.019962 34.648438 end
Thanks!
/Amal
Comment