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
Technical Issues with STATAI want to know if anyone is having the same problem as I do. Every time I paste my data on STATA, it…
How to do a graph like this one in StataDear Statalist, I am trying do replicate (with my own data) a graph like the one I show below. As y…
Returning pointer matrixes in functionsThis idea is probably well known to serious Mata programmers, but I've recently come across what app…
New package: simulate2 and psimulate2Thanks to Kit Baum a new package is available on SSC. simulate2 and psimulate2 enhance and parallali…
Regressing on two years backHi all, until now I have estimated intercepts and coefficients "asking" STATA to do it for each diff…
Subscribe to:
Post Comments (Atom)
0 Response to Create variable of group frequencies
Post a Comment