I have a set of European regions for many different years and I would like to create a variable which identifies each region based on the country it belongs. A small sample of my data looks like this: (note that I have 12 different countries, 100+different regions and my the time period is from 2000 to 2017):

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int time str78 geo str6 value str3 countrycode
2000 "Baden-Württemberg"                  "26,300" "."
2000 "Stuttgart"                           "29,500" "."
2000 "Rheinland-Pfalz"                     "20,600" "."
2000 "Koblenz"                             "19,500" "."
2000 "Trier"                               "17,700" "."
2000 "Rheinhessen-Pfalz"                   "22,200" "."
2000 "Saarland"                            "21,100" "."
2000 "Sachsen"                             "15,100" "."
end
I have generated a countrycode variable and assumed no value for it for the time being.
I would like to input the country code for each region without having to manually select each region as such:

Code:
replace countrycode="LUX" if geo=="Luxembourg"
How do I select a group of regions belonging to the same country and name the variable countrycode with the initials of each country? I tried using this but it does not appear to work (Greece has 13 regions and the country code for Greece is GR):
Code:
replace countrycode="GR" if inlist(geo,Anatoliki Makedonia Thraki,Kentriki Makedonia,Dytiki Makedonia,Ipeiros,Thessalia,Ionia Nisia,Dytiki Ellada,Sterea Ellada,Peloponnisos,Attiki,Voreio Aigaio,Notio Aigaio,Kriti)