I have trouble with generating a specific variable and cleaning my dataset in a certain way. Its quite difficult to explain to someone with no knowledge about my data but I'll try as good as possible.
The data I am using is collected within different areas. I want to create a variable that indicates what the ethnicity of the village leader in that area is.
However, in some areas, there are multiple village leaders, and therefore maybe also multiple ethnicities representing that area. If multiple village leaders in one area have the same ethnicity, there is no problem, but I would like to drop areas where there are multiple village leaders with different ethnicities.
Example data is given below:
Where ea_id corresponds to the area. Ethnicity_10 to the ethnicity of the person (ranging from 1 to 13 for all different ethnicities), and dleader_10 a dummy indicating whether the person is a village leader (1 if leader, 0 if other role).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 ea_id byte ethnicity_10 float dleader_10 "10101016" 4 0 "10101016" 11 1 "10101016" 4 0 "10101016" 11 0 "10101016" 11 0 "10101016" 11 0 "10101204" 11 0 "10101204" 4 0 "10101204" 11 1 "10101204" 11 1 "10101204" 11 0 "10101204" 13 0 "10101215" 11 0 "10101215" 11 0 "10101215" 11 1 "10101215" 11 1 "10101215" 11 0 "10101215" 11 0 "10101562" 11 0 "10101562" 11 0 "10101562" 11 0 "10101562" 11 0 "10101562" 11 0 "10101562" 11 1 "10102004" 13 1 "10102004" 13 0 "10102004" 13 0 "10102004" 13 0 "10102004" 13 1 "10102004" 13 0 "10102004" 13 0 "10103414" 11 1 "10103414" 11 0 "10103414" 11 0 "10103414" 11 1 "10103414" 11 1 "10103414" 11 0 "10104150" 4 0 "10104150" 4 0 "10104150" 4 0 "10104150" 4 0 "10104150" 4 1 "10104150" 4 0 "10104150" 4 1 "10201688" 6 1 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10201688" 6 0 "10202514" 9 1 "10202514" 9 0 "10202514" 9 0 "10202514" 9 0 "10202514" 9 0 "10202514" 9 0 "10202514" 9 0 "10203176" 1 0 "10203176" 4 0 "10203176" 13 1 "10203176" 13 0 "10203176" 13 0 "10203176" 13 0 "10203176" 13 0 "10203744" 4 0 "10203744" 4 0 "10203744" 6 0 "10203744" 6 0 "10203744" 4 0 "10203744" 4 0 "10204322" 13 0 "10204322" 13 0 "10204322" 4 0 "10204322" 4 0 "10204322" 13 0 "10204586" 4 1 "10204586" 4 0 "10204586" 4 0 "10204586" 4 0 "10204586" 4 1 "10204586" 4 0 "10220103" 6 0 "10220103" 6 0 "10220103" 4 0 "10220103" 6 0 "10220103" 4 0 "10220103" 4 0 "10220103" 4 0 "10220705" 6 1 "10220705" 6 0 "10220705" 6 1 "10220705" 6 0 "10220705" 6 1 "10220705" 6 0 "10220705" 6 0 "10301663" 10 1 "10301663" 4 0 end label values ethnicity_10 COM_CB08 label def COM_CB08 1 "CHEWA", modify label def COM_CB08 4 "TUMBUKA", modify label def COM_CB08 6 "NKHONDE", modify label def COM_CB08 9 "NYAKYUSA", modify label def COM_CB08 10 "TONGA", modify label def COM_CB08 11 "LAMBYA", modify label def COM_CB08 13 "SUKWA", modify
0 Response to Problems with generating a variable/cleaning data #2
Post a Comment