Hi,
I am working with DHS data for countries in South Asia and I want to generate a variable for the leave-out-mean of "age at first marriage" within a PSU. I can easily get the mean age of marriage for every PSU by running the cmd: egen mean_age=mean(v511), by(v001) v511: Age at first marriage, v001: PSU number
However, I want the mean to not include the data for the corresponding observation.
I am working with DHS data for countries in South Asia and I want to generate a variable for the leave-out-mean of "age at first marriage" within a PSU. I can easily get the mean age of marriage for every PSU by running the cmd: egen mean_age=mean(v511), by(v001) v511: Age at first marriage, v001: PSU number
However, I want the mean to not include the data for the corresponding observation.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long v001 byte v511 1 16 1 18 1 20 1 19 1 17 1 25 2 20 2 14 2 17 2 14 2 20 2 13 3 22 3 34 3 20 3 18 3 24 3 13 3 16 3 15 3 19 3 16 4 17 4 20 4 22 4 23 4 29 4 23 5 23 5 21 5 23 5 27 5 26 end
Comment