Hello.
I have looked around on the FAQ and this forum, and haven't been able to find an answer.
I need to calculate two weighted means for each country each year in my time series (1990-2019) This needs to be the average of my variable "per402v2" weighted by each party's % voteshare (pervote). Furthermore it needs to be qualified by wether or not a party scores 1 or 0 on either my "opp" variable and my "gov" variable.
To summarise: I need the average of my variable "per402v2" weighted each party's % voteshare, for each year, for each country if the party scores either 1 or 0 on "Opp"
I hope you can help me, thanks in advance.
* Example generated by -dataex-. For more info, type help dataex
clear
input double country2 float year str183 partyname double per402v2 float(opp gov) double pervote
42 2006 "Alliance for the Future of Austria" 2.509 0 1 4.11
42 2007 "Alliance for the Future of Austria" 1.6905 1 0 4.11
42 2008 "Alliance for the Future of Austria" 0.872 1 0 10.7
42 2006 "Austrian People’s Party" 1.505 0 1 34.33
42 2007 "Austrian People’s Party" 1.817 1 0 34.33
42 2008 "Austrian People’s Party" 2.131 0 1 25.98
42 2006 "Austrian Social Democratic Party" 1.248 1 0 35.34
42 2007 "Austrian Social Democratic Party" 1.704 0 1 35.34
42 2008 "Austrian Social Democratic Party" 2.161 0 1 29.26
I have looked around on the FAQ and this forum, and haven't been able to find an answer.
I need to calculate two weighted means for each country each year in my time series (1990-2019) This needs to be the average of my variable "per402v2" weighted by each party's % voteshare (pervote). Furthermore it needs to be qualified by wether or not a party scores 1 or 0 on either my "opp" variable and my "gov" variable.
To summarise: I need the average of my variable "per402v2" weighted each party's % voteshare, for each year, for each country if the party scores either 1 or 0 on "Opp"
I hope you can help me, thanks in advance.
* Example generated by -dataex-. For more info, type help dataex
clear
input double country2 float year str183 partyname double per402v2 float(opp gov) double pervote
42 2006 "Alliance for the Future of Austria" 2.509 0 1 4.11
42 2007 "Alliance for the Future of Austria" 1.6905 1 0 4.11
42 2008 "Alliance for the Future of Austria" 0.872 1 0 10.7
42 2006 "Austrian People’s Party" 1.505 0 1 34.33
42 2007 "Austrian People’s Party" 1.817 1 0 34.33
42 2008 "Austrian People’s Party" 2.131 0 1 25.98
42 2006 "Austrian Social Democratic Party" 1.248 1 0 35.34
42 2007 "Austrian Social Democratic Party" 1.704 0 1 35.34
42 2008 "Austrian Social Democratic Party" 2.161 0 1 29.26
Comment