Please consider the following data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(distid hospid number) 1 1 10 1 2 10 1 3 10 2 2 12 2 1 12 2 3 12 3 2 13 3 3 13 3 1 13 end
Code:
sort distid hospid . . by distid: gen sum=sum( number ) . . by distid: egen total=total( number )
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(distid hospid number sum total) 1 1 10 10 30 1 2 10 20 30 1 3 10 30 30 2 1 12 12 36 2 2 12 24 36 2 3 12 36 36 3 1 13 13 39 3 2 13 26 39 3 3 13 39 39 end
0 Response to Does gen,sum() and egen,total() work differently when combined with bysort?
Post a Comment