Hey Statalists,
Thank you for looking at my posts and providing such a great resource through contributions to this forum (it has helped a lot!). I am pretty new to stata and am having trouble calculating the weighted mean and percentiles for subpopulations in my data set.
About my data:
Census data from 1970 - 2015
What I would like to do:
Calculate the weighted mean, p10, p50, p90 of "wages1999" and using "newwt" as weights for each industry and year. So that in the end I will have e.g. the 10th percentile of wages1991 for industry X in year Y.
Where I am having trouble:
1. egen does not seem to allow for weights
2. pctile does not seem to allow for by's
3. collapse does not seem to allow for a variety of statistical functions (e.g. collapse (mean) wages1999 (p10) wages1999 (p50) wages1999 (p90) wages1999 (p99) wages1999 [aw = new
> wt], by(year ind1990code))
A random sample of 10 observation from my dataset with the relevant variables:
Thank you!
Thank you for looking at my posts and providing such a great resource through contributions to this forum (it has helped a lot!). I am pretty new to stata and am having trouble calculating the weighted mean and percentiles for subpopulations in my data set.
About my data:
Census data from 1970 - 2015
What I would like to do:
Calculate the weighted mean, p10, p50, p90 of "wages1999" and using "newwt" as weights for each industry and year. So that in the end I will have e.g. the 10th percentile of wages1991 for industry X in year Y.
Where I am having trouble:
1. egen does not seem to allow for weights
2. pctile does not seem to allow for by's
3. collapse does not seem to allow for a variety of statistical functions (e.g. collapse (mean) wages1999 (p10) wages1999 (p50) wages1999 (p90) wages1999 (p99) wages1999 [aw = new
> wt], by(year ind1990code))
A random sample of 10 observation from my dataset with the relevant variables:
Code:
input int year float(ind1990code wages1999 newwt) 1970 60 12031 194000 1970 251 13847 261000 1970 682 2497 36375 1980 712 25118.775 204000 1980 732 36616.727 204000 1980 831 7217.775 81600 1990 831 38976 274176 2000 162 26900 125280 2000 351 57000 361080 2015 842 55200 118320 end
Comment