Could someone possibly help me with merging some data from long to wide?
Apologies for not using dataex - my University is having problems with their STATA licence currently.
I have a dataset in long format, with multiple creatinine test results ("creatinine") for each person (ID). Each test result is associated with a time in days ("timetocreat"), and on occasion there are multiple test results for the same ID at the same time (such that "ID" and "timetocreat" are similar but "creatinine" is different). To try to overcome this I created an additional "obs no" which is distinct to each line of data.
Example here:
What I would like is a single line of data per ID, with all the creatinine values, and associated times, on that single line.
I have (most lately!) tried this command as follows:
reshape wide creatinine timetocreat, i(ID) j (obs_no)
However I receive an error command saying there are too many distinct observations for "obs no".
Could someone kindly point out where I am going wrong?
Thankyou
Jemima Scott
Apologies for not using dataex - my University is having problems with their STATA licence currently.
I have a dataset in long format, with multiple creatinine test results ("creatinine") for each person (ID). Each test result is associated with a time in days ("timetocreat"), and on occasion there are multiple test results for the same ID at the same time (such that "ID" and "timetocreat" are similar but "creatinine" is different). To try to overcome this I created an additional "obs no" which is distinct to each line of data.
Example here:
| ID | Timetocreat | Creatinine | Obs no |
| 1 | 0 | 115 | 1 |
| 1 | 1 | 110 | 2 |
| 2 | 0 | 256 | 3 |
| 2 | 0 | 280 | 4 |
| 2 | 1 | 310 | 5 |
| 2 | 8 | 420 | 6 |
| 3 | 0 | 86 | 7 |
I have (most lately!) tried this command as follows:
reshape wide creatinine timetocreat, i(ID) j (obs_no)
However I receive an error command saying there are too many distinct observations for "obs no".
Could someone kindly point out where I am going wrong?
Thankyou
Jemima Scott

Comment