Hello to all
For my panel data set whose unit of analysis is country, I would like to identify the neighboring countries for each country, then I would like to create a matrix and use it to calculate the average of each country of these countries .

EXAMPLE : The neighboring countries of FRANCE (BELGIUM LUXEMBOURG GERMANY SWITZERLAND ITALY ) use the GVC value of these neighboring countries to calculate a matrix to have a result for FRANCE year by year.

I would be very happy to have some advice. Thanks in advance !

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str14 A byte B str4 C str10 D str18(E F G)
""         . "Year" "GVC"       "due_to_within_EU28" "due_to_income_EU28" "due_to_pop_EU28"   
"Austria"  1 "1990" "29805700"  ".0481634656111964"  ".9024480458070983"  "-.0191678639953992"
"Austria"  1 "1991" "30938910"  ".1836609116141972"  "1.944608703151403"  "-.0441903522094975"
"Austria"  1 "1992" "34690810"  ".374990608645696"   "2.423186855571203"  "-.0670849539272993"
"Austria"  1 "1993" "30951600"  ".6465782510456961"  "2.387666853502203"  "-.0922915704774994"
"Austria"  1 "1994" "34472510"  ".8342666347497953"  "2.295696995644306"  "-.1160531306933024"
"Austria"  1 "1995" "43642010"  ".9401863633068999"  "1.998167904203711"  "-.1434793089426023"
"Austria"  1 "1996" "45747690"  ".8188593139070974"  "1.78346026440601"   "-.1607268091505034"
"Austria"  1 "1997" "44950790"  ".7875487975271014"  "1.81007552918431"   "-.1758015333879044"
"Austria"  1 "1998" "47853380"  ".8011219821127966"  "1.812754054488806"  "-.1918774365390092"
"Austria"  1 "1999" "48544530"  ".8388342510556939"  "1.901551387258806"  "-.2060778344974139"
"Austria"  1 "2000" "49766170"  ".8847901921023933"  "1.826584293540904"  "-.2273702337304115"
"Austria"  1 "2001" "52696490"  ".9489439828825965"  "1.672656645632905"  "-.2585411221463119"
"Austria"  1 "2002" "56400760"  ".9532259074613947"  "1.385412068788604"  "-.3050060786057145"
"Austria"  1 "2003" "71220730"  "1.076461129929193"  "1.097109321098706"  "-.3292282168301099"
"Austria"  1 "2004" "92070150"  "1.312537125220892"  ".783644244392903"   "-.3445579339966116"
"Austria"  1 "2005" "101081500" "1.408761366994995"  ".5412083125216043"  "-.3630515445323113"
"Austria"  1 "2006" "124432900" "1.469008083114495"  ".2761671932472041"  "-.3780829601737068"
"Austria"  1 "2007" "155928200" "1.527217282333993"  ".0185255577209986"  "-.3913022873326071"
"Austria"  1 "2008" "183194900" "1.622884240942696"  "-.3050427344651965" "-.4098649309953046"
"Austria"  1 "2009" "142540500" "1.649642827765895"  "-.444219273757902"  "-.420585170634709" 
"Austria"  1 "2010" "173373400" "1.754465818836096"  "-.3424530512790014" "-.4334694235139054"
"Austria"  1 "2011" "190063200" "1.820813707667696"  "-.3540547723328018" "-.4506867045009031"
"Austria"  1 "2012" "187674200" "1.930985100447394"  "-.4128715802334995" "-.4611845414062046"
"Austria"  1 "2013" "196076500" "2.022298897724198"  "-.4191095057589962" "-.4715954975592993"
"Austria"  1 "2014" "205255700" "1.9478777170334"    "-.4614612203901984" "-.4817944606082989"
"Austria"  1 "2015" "174853500" "1.921528790290004"  "-.4723106970221949" "-.4926251645836004"
"Austria"  1 "2016" "178600100" "1.945843827191304"  "-.5911460549507979" "-.5033391209945037"
"Austria"  1 "2017" "185883700" "1.841171280076601"  "-.7111840237362017" "-.5109963075212036"
"Belgium"  2 "1990" "97696230"  ".0481634656111964"  ".9024480458070983"  "-.0191678639953992"
"Belgium"  2 "1991" "102237000" ".1836609116141972"  "1.944608703151403"  "-.0441903522094975"
"Belgium"  2 "1992" "116127100" ".374990608645696"   "2.423186855571203"  "-.0670849539272993"
"Belgium"  2 "1993" "105241000" ".6465782510456961"  "2.387666853502203"  "-.0922915704774994"
"Belgium"  2 "1994" "117889000" ".8342666347497953"  "2.295696995644306"  "-.1160531306933024"
"Belgium"  2 "1995" "144896900" ".9401863633068999"  "1.998167904203711"  "-.1434793089426023"
"Belgium"  2 "1996" "147398200" ".8188593139070974"  "1.78346026440601"   "-.1607268091505034"
"Belgium"  2 "1997" "141897800" ".7875487975271014"  "1.81007552918431"   "-.1758015333879044"
"Belgium"  2 "1998" "145804000" ".8011219821127966"  "1.812754054488806"  "-.1918774365390092"
"Belgium"  2 "1999" "146973000" ".8388342510556939"  "1.901551387258806"  "-.2060778344974139"
"Belgium"  2 "2000" "151373300" ".8847901921023933"  "1.826584293540904"  "-.2273702337304115"
"Belgium"  2 "2001" "155192100" ".9489439828825965"  "1.672656645632905"  "-.2585411221463119"
"Belgium"  2 "2002" "165131500" ".9532259074613947"  "1.385412068788604"  "-.3050060786057145"
"Belgium"  2 "2003" "203479000" "1.076461129929193"  "1.097109321098706"  "-.3292282168301099"
"Belgium"  2 "2004" "254260000" "1.312537125220892"  ".783644244392903"   "-.3445579339966116"
"Belgium"  2 "2005" "278069300" "1.408761366994995"  ".5412083125216043"  "-.3630515445323113"
"Belgium"  2 "2006" "328224800" "1.469008083114495"  ".2761671932472041"  "-.3780829601737068"
"Belgium"  2 "2007" "399167100" "1.527217282333993"  ".0185255577209986"  "-.3913022873326071"
"Belgium"  2 "2008" "471904900" "1.622884240942696"  "-.3050427344651965" "-.4098649309953046"
"Belgium"  2 "2009" "377217400" "1.649642827765895"  "-.444219273757902"  "-.420585170634709" 
"Belgium"  2 "2010" "447540900" "1.754465818836096"  "-.3424530512790014" "-.4334694235139054"
"Belgium"  2 "2011" "476072700" "1.820813707667696"  "-.3540547723328018" "-.4506867045009031"
"Belgium"  2 "2012" "471962500" "1.930985100447394"  "-.4128715802334995" "-.4611845414062046"
"Belgium"  2 "2013" "494917700" "2.022298897724198"  "-.4191095057589962" "-.4715954975592993"
"Belgium"  2 "2014" "517249300" "1.9478777170334"    "-.4614612203901984" "-.4817944606082989"
"Belgium"  2 "2015" "462273700" "1.921528790290004"  "-.4723106970221949" "-.4926251645836004"
"Belgium"  2 "2016" "485990500" "1.945843827191304"  "-.5911460549507979" "-.5033391209945037"
"Belgium"  2 "2017" "508085700" "1.841171280076601"  "-.7111840237362017" "-.5109963075212036"
"Bulgaria" 3 "1990" "1897707"   ".0481634656111964"  ".9024480458070983"  "-.0191678639953992"
"Bulgaria" 3 "1991" "1501139"   ".1836609116141972"  "1.944608703151403"  "-.0441903522094975"
"Bulgaria" 3 "1992" "1880353"   ".374990608645696"   "2.423186855571203"  "-.0670849539272993"
"Bulgaria" 3 "1993" "1723912"   ".6465782510456961"  "2.387666853502203"  "-.0922915704774994"
"Bulgaria" 3 "1994" "1887298"   ".8342666347497953"  "2.295696995644306"  "-.1160531306933024"
"Bulgaria" 3 "1995" "2491514"   ".9401863633068999"  "1.998167904203711"  "-.1434793089426023"
"Bulgaria" 3 "1996" "2505765"   ".8188593139070974"  "1.78346026440601"   "-.1607268091505034"
"Bulgaria" 3 "1997" "2769917"   ".7875487975271014"  "1.81007552918431"   "-.1758015333879044"
"Bulgaria" 3 "1998" "2872591"   ".8011219821127966"  "1.812754054488806"  "-.1918774365390092"
"Bulgaria" 3 "1999" "2894217"   ".8388342510556939"  "1.901551387258806"  "-.2060778344974139"
"Bulgaria" 3 "2000" "2948860"   ".8847901921023933"  "1.826584293540904"  "-.2273702337304115"
"Bulgaria" 3 "2001" "2972950"   ".9489439828825965"  "1.672656645632905"  "-.2585411221463119"
"Bulgaria" 3 "2002" "3236181"   ".9532259074613947"  "1.385412068788604"  "-.3050060786057145"
"Bulgaria" 3 "2003" "4059918"   "1.076461129929193"  "1.097109321098706"  "-.3292282168301099"
"Bulgaria" 3 "2004" "5344343"   "1.312537125220892"  ".783644244392903"   "-.3445579339966116"
"Bulgaria" 3 "2005" "5499580"   "1.408761366994995"  ".5412083125216043"  "-.3630515445323113"
"Bulgaria" 3 "2006" "8273654"   "1.469008083114495"  ".2761671932472041"  "-.3780829601737068"
"Bulgaria" 3 "2007" "10386200"  "1.527217282333993"  ".0185255577209986"  "-.3913022873326071"
"Bulgaria" 3 "2008" "12811460"  "1.622884240942696"  "-.3050427344651965" "-.4098649309953046"
"Bulgaria" 3 "2009" "9413788"   "1.649642827765895"  "-.444219273757902"  "-.420585170634709" 
"Bulgaria" 3 "2010" "12147060"  "1.754465818836096"  "-.3424530512790014" "-.4334694235139054"
"Bulgaria" 3 "2011" "14525560"  "1.820813707667696"  "-.3540547723328018" "-.4506867045009031"
"Bulgaria" 3 "2012" "14306560"  "1.930985100447394"  "-.4128715802334995" "-.4611845414062046"
"Bulgaria" 3 "2013" "14811590"  "2.022298897724198"  "-.4191095057589962" "-.4715954975592993"
"Bulgaria" 3 "2014" "15562760"  "1.9478777170334"    "-.4614612203901984" "-.4817944606082989"
"Bulgaria" 3 "2015" "13264430"  "1.921528790290004"  "-.4723106970221949" "-.4926251645836004"
"Bulgaria" 3 "2016" "13868150"  "1.945843827191304"  "-.5911460549507979" "-.5033391209945037"
"Bulgaria" 3 "2017" "14494140"  "1.841171280076601"  "-.7111840237362017" "-.5109963075212036"
"Croatia"  4 "1990" "1292701"   ".0481634656111964"  ".9024480458070983"  "-.0191678639953992"
"Croatia"  4 "1991" "1342475"   ".1836609116141972"  "1.944608703151403"  "-.0441903522094975"
"Croatia"  4 "1992" "1278446"   ".374990608645696"   "2.423186855571203"  "-.0670849539272993"
"Croatia"  4 "1993" "1161347"   ".6465782510456961"  "2.387666853502203"  "-.0922915704774994"
"Croatia"  4 "1994" "1278436"   ".8342666347497953"  "2.295696995644306"  "-.1160531306933024"
"Croatia"  4 "1995" "1499801"   ".9401863633068999"  "1.998167904203711"  "-.1434793089426023"
"Croatia"  4 "1996" "1686822"   ".8188593139070974"  "1.78346026440601"   "-.1607268091505034"
"Croatia"  4 "1997" "1771090"   ".7875487975271014"  "1.81007552918431"   "-.1758015333879044"
"Croatia"  4 "1998" "1875018"   ".8011219821127966"  "1.812754054488806"  "-.1918774365390092"
"Croatia"  4 "1999" "1874454"   ".8388342510556939"  "1.901551387258806"  "-.2060778344974139"
"Croatia"  4 "2000" "2185950"   ".8847901921023933"  "1.826584293540904"  "-.2273702337304115"
"Croatia"  4 "2001" "2262487"   ".9489439828825965"  "1.672656645632905"  "-.2585411221463119"
"Croatia"  4 "2002" "2448941"   ".9532259074613947"  "1.385412068788604"  "-.3050060786057145"
"Croatia"  4 "2003" "3073162"   "1.076461129929193"  "1.097109321098706"  "-.3292282168301099"
"Croatia"  4 "2004" "3927037"   "1.312537125220892"  ".783644244392903"   "-.3445579339966116"
end
------------------ copy up to and including the previous line ------------------

Listed 100 out of 785 observations
Use the count() option to list more

neighboring countries is

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str14(A B)
"Austria"        "Czech Republic"
"Austria"        "Germarny "     
"Austria"        "Hungary"       
"Austria"        "Italy"         
"Austria"        "Slovakia"      
"Austria"        "Slovenia"      
"Belgium"        "France"        
"Belgium"        "Germarny "     
"Belgium"        "Luxembourg"    
"Belgium"        "Netherlands"   
"Bulgaria"       "Greece"        
"Bulgaria"       "Romania"       
"Croatia"        "Hungary"       
"Croatia"        "Slovenia"      
"Cyprus"         "UK"            
"Czech Republic" "Austria"       
"Czech Republic" "Germarny "     
"Czech Republic" "Poland"        
"Czech Republic" "Slovakia"      
"Denmark"        "Germarny "     
"Estonia"        "Latvia"        
"Finland"        "Sweden"        
"France"         "Belgium"       
"France"         "Germarny "     
"France"         "Italy"         
"France"         "Spain"         
"France"         "Luxembourg"    
"Germany"        "Austria"       
"Germany"        "Belgium"       
"Germany"        "Poland"        
"Germany"        "Czech Republic"
"Germany"        "Denmark"       
"Germany"        "France"        
"Germany"        "Luxembourg"    
"Germany"        "Netherlands"   
"Greece"         "Bulgaria"      
"Hungary"        "Austria"       
"Hungary"        "Croatia"       
"Hungary"        "Romania"       
"Hungary"        "Slovakia"      
"Hungary"        "Slovenia"      
"Ireland"        "UK"            
"Italy"          "Austria"       
"Italy"          "France"        
"Italy"          "Slovenia"      
"Latvia"         "Estonia"       
"Lithuania"      "Latvia"        
"Lithuania"      "Poland"        
"Latvia"         "Lithuania"     
"Luxembourg"     "Belgium"       
"Luxembourg"     "France"        
"Luxembourg"     "Germany"       
"Malta"          ""              
"Netherlands"    "Belgium"       
"Netherlands"    "Germany"       
"Poland"         "Czech Republic"
"Poland"         "Germany"       
"Poland"         "Lithuania"     
"Poland"         "Slovakia"      
"Portugal"       "Spain"         
"Romania"        "Bulgaria"      
"Romania"        "Hungary"       
"Slovakia"       "Austria"       
"Slovakia"       "Czech Republic"
"Slovakia"       "Poland"        
"Slovakia"       "Hungary"       
"Slovenia"       "Austria"       
"Slovenia"       "Croatia"       
"Slovenia"       "Italy"         
"Slovenia"       "Hungary"       
"Spain"          "France"        
"Spain"          "Portugal"      
"Sweden"         "Finland"       
"UK"             "Cyprus"        
"UK"             "Ireland"       
"UK"             "Spain"         
end
------------------ copy up to and including the previous line ------------------

Listed 76 out of 76 observations