Hi!
I am working with quite large dataset, which consists of both "fixed" variables (like ID, gender, date of birth, date of hospitalization, initial treatment, previous diseases) as well as variables containing longitudinal data (like ldl-cholesterol, blood pressure, employment status) assessed at certain time points (at baseline, after two weeks, after 3months etc). An example from the dataset:
I have tried to read other posts on how to reshape data from wide to long, but I see that there are different advices in different situations, so I decided to ask to be sure I apply the right commands. I firstly renamed all the time-dependent variables to be compatible for long format by using rename command, as in examples below:
rename d00* *00
rename d14* *01
rename m06* *06
The dataset is quite large and I wonder if there is better way to do it than using the standard command (reshape long varname, i(ID) j(time) ).
Thanks for your attention!
I am working with quite large dataset, which consists of both "fixed" variables (like ID, gender, date of birth, date of hospitalization, initial treatment, previous diseases) as well as variables containing longitudinal data (like ldl-cholesterol, blood pressure, employment status) assessed at certain time points (at baseline, after two weeks, after 3months etc). An example from the dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str6 Gender str19 Treatment double(d00ldl d14ldl m03ldl m06ldl) float(d00arbeid d14arbeid m03arbeid m06arbeid) "Mann" "PCI-medikamentstent" 7 3.1 2.8 2.2 1 0 0 0 "Mann" "PCI-medikamentstent" 2.2 2 2.2 2.2 1 0 0 1 "Mann" "PCI-metallstent" 3.2 3.3 3.3 2.9 1 0 1 1 "Kvinne" "PCI-metallstent" 3.3 2.4 2.3 2.2 1 1 1 1 "Mann" "PCI-medikamentstent" 2.4 . . . 1 . . . "Mann" "PCI-medikamentstent" 4.7 2.3 2.1 2.2 0 0 0 0 "Mann" "POBA" 3 2.1 1.8 1.7 0 0 0 0 "Mann" "PCI-medikamentstent" 4.1 . . . 0 . . . "Mann" "PCI-medikamentstent" 2.6 2.9 2.4 2.6 0 0 0 0 "Mann" "PCI-medikamentstent" 2.3 . . . 1 . . . end label values d00arbeid neija label values d14arbeid neija label values m03arbeid neija label values m06arbeid neija label def neija 0 "Nei", modify label def neija 1 "Ja", modify
rename d00* *00
rename d14* *01
rename m06* *06
The dataset is quite large and I wonder if there is better way to do it than using the standard command (reshape long varname, i(ID) j(time) ).
Thanks for your attention!
Comment