Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(date_daily_3 date_daily_4 date_daily_5 date_daily_6) long(time_3 time_4 time_5 time_6) float(med_dose_3 med_dose_4 med_dose_5 med_dose_6)
22027 22028 22028 22029 68400000 25200000 68400000 25200000 48 48 48 .
21832 21832 21832 21833 29400000 63600000 72600000 30300000 36  . 36 .
21713 21714 21715     .        1        1        1        . 36 36 36 .
end
format %tdMon_dd,_CCYY date_daily_3
format %tdMon_dd,_CCYY date_daily_4
format %tdMon_dd,_CCYY date_daily_5
format %tdMon_dd,_CCYY date_daily_6
format %tchh:MM:SS_AM time_3
format %tchh:MM:SS_AM time_4
format %tchh:MM:SS_AM time_5
format %tchh:MM:SS_AM time_6

Dear all,

I have longitudinal data with patient data collected through multiple days and multiple times per day.
I would like to obtain the total dose (in milligrams) administered per day from the variable med_dose (is there an egen command for this?)

For example for the first observation, I would like to obtain a variable called total_dose= med_dose_4+ med_dose_5 because these doses(med_dose_4 =48 and med_dose_5= 48) were both administered on the 23rd of april 2020 and therefore I need to sum them.
Thank you.

Jules