I have a data set that includes variables on individual's district (where a person lives) and occupation. I am trying to generate a new variable that tells me the occupation shares by district; i.e. if there are 10 people in the 1st district and 3 are farmers, I want the new variable created to say 0.3 for everyone that is a farmer in that district. Thus far I have tried:
bysort district: tab occupation
however, as there are over 600 districts in the sample, it would be very labor intensive to enter all the frequencies by hand. I have also tried
egen freq=pc(occupation), by(district) prop
but this does not return that correct proportions.
I would really appreciate help with this. Thanks!
Related Posts with Create variable of group frequencies
Econometrics questions : Functional form choiceHi statalist, I try to estimate the effect of a monetary bonus on physicians’ activity. I would lik…
Extracting the column percentages from two tabDear Statalist, I need to calculate the difference between two percentages coming from two different…
competing risk without covariatesI want to compare the risk of dying of a specific cancer versus "other causes" in a large sample. Co…
Fixing Scientific Notation in String VariableHi I have a dataset containing many observations. All variables are string variables (Type: str40 …
reg i.id i.year,vce(cl id) vs. xtreg i.year,fe rDear all, We know "reg i.id i.year,vce(cl id)" is the same as "xtreg i.year,fe r",but why are the re…
Subscribe to:
Post Comments (Atom)
0 Response to Create variable of group frequencies
Post a Comment