Hello all,

I would like to ask how to combine/sum up data from duplicate observations. In the below data example, I would like to combine drug dose (dose) for each individual (id) who was prescribed "drug H" for multiple times.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(id dose) long act_n
 108  50 64
 108  50 64
 108  50 64
 108  50 64
 108 100 64
 240  50 64
 240  50 64
 240  50 64
 240  50 64
 240  50 64
 240  50 64
 240  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 347  50 64
 555  50 64
 555  50 64
 555  50 64
 555  50 64
 555  50 64
 555  50 64
 555  50 64
 555  50 64
 589  50 64
 589  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
 996  50 64
1324  50 64
1324  50 64
1324  50 64
1324  50 64
1324  50 64
1324  50 64
1324  50 64
1324  50 64
1351  50 64
1632 100 64
1877 100 64
2541  50 64
2541  50 64
2541  50 64
2541  50 64
2541  50 64
2541  50 64
2541  50 64
2664  50 64
3045  50 64
3045  50 64
3045  50 64
3045  50 64
3045  50 64
3951  50 64
4272 100 64
4624  50 64
5065  50 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090 100 64
6090  50 64
end
label values act_n act_n_lb
label def act_n_lb 64 " Drug H", modify
I used
Code:
collapse (sum) dose, by (id)
but it deleted other variables (act_n).
Pls kindly suggest the command to combine the data from duplicate observations. I am using Stata 13.0 by the way.

Thank in advance.

Best Regards,
Moon Lu