Hi everyone, I'm new to stata, so any advice on how to code this would be greatly appreciated.
I have medication data for 1500 patients. Each row represents a unique medication ID, so each patient may be represented in multiple rows if he/she has multiple meds (example below). I'd like to create a summary variable (ie, Total_Meds) that equals the total number of meds assigned to each patient; and assign it to the individual patient. For example, Total_Meds would equal 4 for the 1st patient below. Thanks in advance.
Patient_ID_____________ Med_ID
543789347___________________5435
543789347___________________9812
543789347___________________3242
543789347___________________1290
189340584__________________4590
189340584__________________9812
189340584_________________ 1290
483908535__________________5435
483908535_________________ 1290
483908535__________________5490
483908535__________________4334
etc.
etc.
I have medication data for 1500 patients. Each row represents a unique medication ID, so each patient may be represented in multiple rows if he/she has multiple meds (example below). I'd like to create a summary variable (ie, Total_Meds) that equals the total number of meds assigned to each patient; and assign it to the individual patient. For example, Total_Meds would equal 4 for the 1st patient below. Thanks in advance.
Patient_ID_____________ Med_ID
543789347___________________5435
543789347___________________9812
543789347___________________3242
543789347___________________1290
189340584__________________4590
189340584__________________9812
189340584_________________ 1290
483908535__________________5435
483908535_________________ 1290
483908535__________________5490
483908535__________________4334
etc.
etc.