Reputation: 317
I have the following two variables, and I am trying to compute the unemployment rate with each observation's individual weight. The first variable below shows the weight given to each individual respondent, while the second variable shows whether the person is unemployed where 1 indicates the individual is unemployed, and 0 if they are working. Finally, LF_status indicates in string format the labor force status.
dataex (ind_wt unemp_status) LF_status
.42645285 0 emp
.11840937 1 unemp
.11849173 0 emp
1.49918 1 unemp
I have taken Cybernike's post, and the values for the newly created weighted unemployment variable looks as follows for all observations, does that make sense?
egen unemployment_weighted= wtmean(unemp_status), weight(ind_wt)
dataex unemployment_weighted
.3786077
.3786077
.3786077
.3786077
Upvotes: 0
Views: 4034
Reputation: 1103
You can use the _GWTMEAN
package from SSC to do this. There are probably other ways too.
ssc install _gwtmean
egen wanted = wtmean(unemp_status), weight(ind_wt)
. list
+--------------------------------+
| ind_wt unemp_~s wanted |
|--------------------------------|
1. | .4264528 0 .5549336 |
2. | .1184094 . .5549336 |
3. | .1184917 0 .5549336 |
4. | 1.49918 0 .5549336 |
5. | .7357956 . .5549336 |
|--------------------------------|
6. | .8300208 0 .5549336 |
7. | 4.741648 0 .5549336 |
8. | 9.495796 1 .5549336 |
+--------------------------------+
Upvotes: 2