Hello everyone,


I have to compute the weighted average of democratic scores in the destination countries, weighted it with my shares of emigrants in a certain province in a year.
This is the Stata command i am using:

bysort provincia year: asgen weighted_average= democracy_polity if democracy_polity!=. & share_emigration!=., weight(share_emigration)

However, the new variables doe not make much sense since the values do not sum up to 1.

Thank you,
Best,
Margherita