Hi all, I have a dataset where some (but not all) individuals have multiple rows. My primary goal is to produce a dataset at the individual level, where I sum together the costs for those who have multiple rows, while retaining their information that does not need to be summed (in my data example, that'd be race, gender, and survey weight). What is the most efficient way to do this?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte id int cost1 byte(cost2 race gender) double surv_weight 1 43 55 1 0 .98 1 23 43 1 0 .98 2 155 53 1 1 1.04 2 9 34 1 1 1.04 3 67 76 3 1 .77 4 26 45 2 0 .97 4 64 52 2 0 .97 5 34 79 1 0 1.1 end
Comment