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
how do we interpret the results from a Nonparametric series regressionI am analyzing a dataset (n=38, total 4 groups (3 groups of 10 each and 8 controls)) on occurance of…
simulation not working (running only once)Hi, Stata people. I am really sorry to post this again. I am assigning random treatment and then wan…
Test of mean differencesWhat is the correct command to use when I want to compare groups that are nested within each other? …
IV(2SLS) regression with fixed effects and two-way clusteringHello, I tired IV(2SLS) regression with STATA, but I do not know whether what I do is right or not.…
Box Whisker Plot HelpHello: I would like to make a box whisker plot where the y axis is age and the boxes are 2 differen…
Subscribe to:
Post Comments (Atom)
0 Response to Create variable of group frequencies
Post a Comment