Dear All,
I have data for the monthly wage by gender and categories of commuting time. I am trying to calculate the weighted average of the monthly wage by using the number of people in each commuting category by gender. An example of the data is shown below.
I tried the following codes but it only gave me the average not the weighted average:
Many thanks,
Maye
I have data for the monthly wage by gender and categories of commuting time. I am trying to calculate the weighted average of the monthly wage by using the number of people in each commuting category by gender. An example of the data is shown below.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(commute female mnthwg)
1 0 500
1 1 1883.3334
1 0 198.33333
1 0 600
1 1 400
1 0 1500
1 1 345
1 0 1188.5714
1 0 364
1 0 550
end
label values commute commutecate
label def commutecate 1 "less than 16 min." ///
2 "from 16 to 32 min." ///
3 "from 33 to 60 min." ///
4 "from 61 to 90 min." ///
5 "from 91 to 720 min.", modify
label values female sex
label def sex 0 "male", modify
label def sex 1 "female", modify
Code:
egen weightwage = wtmean(mnthwg), weight(commute)
Maye

Comment