Hi all,
I have a dataset with upwards of 100k observations. Each observation is stratified first by union and then by village. The number of groups pertains to the village level. I want to generate a variable that sums the total number of groups within each village of the union. However, when I do egen qualified_farming_union = total(village_farming_group), by(vidunion) it gives me the total from all instances. Each instance within a village is not unique and upto the village each value is distinct. Here's an example -
Is it possible to get a variable which would only sum one value for each distinct village within a union? Thanks!
I have a dataset with upwards of 100k observations. Each observation is stratified first by union and then by village. The number of groups pertains to the village level. I want to generate a variable that sums the total number of groups within each village of the union. However, when I do egen qualified_farming_union = total(village_farming_group), by(vidunion) it gives me the total from all instances. Each instance within a village is not unique and upto the village each value is distinct. Here's an example -
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(vidunion vidvillage) float(village_farming_group village_aquaculture_group village_fishing_group) 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . 1 1001 2 . . end label values vidunion labels2 label values vidvillage labels3
Comment