I have some healthcare utilization data in the long format and would like to create simple data descriptives. The data looks like somewhat like this:
nurseID | date | activity_code | mins_worked | region | volume |
H01 | 13 jul 2004 | 2 | 120 | R | 1 |
H01 | 13 jul 2004 | 4,5 | 120 | R | 1 |
H01 | 13 jul 2004 | 1 | 120 | R | 1 |
H01 | 13 jul 2004 | 4,7 | 120 | R | 1 |
H01 | 03 aug 2004 | 1,2 | 90 | R | 1 |
H01 | 03 aug 2004 | 3.6 | 90 | R | 1 |
H02 | 15 jul 2004 | 1,4 | 120 | M | 0 |
with mins_worked being the total of the duration worked for by each nurse on different activities (as shown under activity_code). What I'm trying to do is to present the average number of mins_worked for each nurseID on a specific date. I tried to do this with -
Code:
bysort nurseID date: egen Mean = mean(mins_worked)
but it provides me with a mean for each group (nurseID date) instead of averaging across the unique values of mins_worked over nurseID and date. For the small data table presented above, the answer I'd like to get is (120+90+120)/3=110. I'd also like to present the average mins_worked over different identifiers such as region and volume.
Thanks!
0 Response to Summarizing variable across/over groups
Post a Comment