Hello,
I am working with an annual panel data from 5 European countries (2000-2005). For each country and year, I have a variable x and the distance of that country's capital from each of the other country's capital cities (kmdist). For each country-year observation, I want to calculate the mean of x of all other countries, weighted by the kmdist of each country. E.g., for Austria in 2000, I want to compute the average of x for Belgium, Czech, and Denmark in 2000, weighted by their respective kmdist variables.
I am quite lost on how to start. Any advice would be greatly appreciated!
Below is an extract of the data.
Many thanks,
Mihir
I am working with an annual panel data from 5 European countries (2000-2005). For each country and year, I have a variable x and the distance of that country's capital from each of the other country's capital cities (kmdist). For each country-year observation, I want to calculate the mean of x of all other countries, weighted by the kmdist of each country. E.g., for Austria in 2000, I want to compute the average of x for Belgium, Czech, and Denmark in 2000, weighted by their respective kmdist variables.
I am quite lost on how to start. Any advice would be greatly appreciated!
Below is an extract of the data.
Many thanks,
Mihir
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str14 country int year float x int(kmdistAustria kmdistBelgium kmdistCzech kmdistDenmark) "Austria" 2000 -.1725926 . 903 259 827 "Austria" 2001 -.11703704 . 903 259 827 "Austria" 2002 -.018518522 . 903 259 827 "Austria" 2003 .04962962 . 903 259 827 "Austria" 2004 .10518519 . 903 259 827 "Austria" 2005 .12666667 . 903 259 827 "Belgium" 2000 -.1688889 903 . 725 781 "Belgium" 2001 -.10888889 903 . 725 781 "Belgium" 2002 -.010370375 903 . 725 781 "Belgium" 2003 .05777777 903 . 725 781 "Belgium" 2004 .11333334 903 . 725 781 "Belgium" 2005 .13111112 903 . 725 781 "Czech Republic" 2000 -.1514815 259 725 . 577 "Czech Republic" 2001 -.09148148 259 725 . 577 "Czech Republic" 2002 .02296296 259 725 . 577 "Czech Republic" 2003 .0911111 259 725 . 577 "Czech Republic" 2004 .12777779 259 725 . 577 "Czech Republic" 2005 .12518519 259 725 . 577 "Denmark" 2000 -.1851852 827 781 577 . "Denmark" 2001 -.1525926 827 781 577 . "Denmark" 2002 -.05407408 827 781 577 . "Denmark" 2003 .01407407 827 781 577 . "Denmark" 2004 .06962963 827 781 577 . "Denmark" 2005 .0874074 827 781 577 .
Comment