Hello,
I need help with a simple loop.
I need to create a proportion of caste group per village variable. At the moment I have variables of caste and share separately and there can be up to 7 caste groups per village (which may repeat because they are aggregated from subgroups). Overall there are 5 major groups.
For example, I have caste groups recorded in A-G --- variables v2A - v2G - for different castes per village and I have v4A-v4G for proportion of this caste per village respectively.
I need to sum up these A-G for each caste, and there are 5 types of caste groups.
if done manually I guess it would look something like this: egen caste1=rowtotal(v2A v2B.....etc) if V4A==1 & V4B==1 & (for caste1 and the same for caste 4-5)
I cannot figure out what would be a more efficient loop?
Thanks for helping out!
I need help with a simple loop.
I need to create a proportion of caste group per village variable. At the moment I have variables of caste and share separately and there can be up to 7 caste groups per village (which may repeat because they are aggregated from subgroups). Overall there are 5 major groups.
For example, I have caste groups recorded in A-G --- variables v2A - v2G - for different castes per village and I have v4A-v4G for proportion of this caste per village respectively.
I need to sum up these A-G for each caste, and there are 5 types of caste groups.
if done manually I guess it would look something like this: egen caste1=rowtotal(v2A v2B.....etc) if V4A==1 & V4B==1 & (for caste1 and the same for caste 4-5)
I cannot figure out what would be a more efficient loop?
Thanks for helping out!
Comment