Hi all,
I have a dataset with aggregated data for several European countries and NUTS-2 regions within them, inluding data on the average ideology on a left-right scale (ideology) and the average satisfaction with democracy within each region (demosat). I also have spatial lat-long data for each region. This is what the data looks like:
I would like to create new observations that consist of every possible combination of pairs of regions within a country. Additionally, I want the explanatory variables of those newly created region pairs (ideology, demosat) to take on the difference in values between those two regions and - on the basis of the lat-long variables - also create a new variable that contains the geographical distance between those two regions in km for each pair. Is something like that possible?
I would greatly appreciate any help.
I'm currently using STATA 15.1 if that matters.
Kind regards,
Florian
I have a dataset with aggregated data for several European countries and NUTS-2 regions within them, inluding data on the average ideology on a left-right scale (ideology) and the average satisfaction with democracy within each region (demosat). I also have spatial lat-long data for each region. This is what the data looks like:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str24 country str5 nuts_id float(latitude longitude ideology demosat) "Austria" "AT11" 2700481.5 4796796.5 4.1857142 3.5 "Austria" "AT12" 2810612 4748394.5 5.024038 3.608511 "Austria" "AT13" 2808263 4795769 4.7064934 3.718182 "Austria" "AT21" 2632784.5 4662314.5 4.6597223 3.352941 "Austria" "AT22" 2689864 4739647.5 5.038869 3.105769 "Austria" "AT31" 2788914 4614961 4.568915 3.3439155 "Austria" "AT32" 2690008 4548079.5 4.790698 3.6267605 "Austria" "AT33" 2674450 4378918 5 3.564516 "Austria" "AT34" 2680342.5 4312294.5 4.7352943 3.6756756 "Belgium" "BE1" 3096269 3923952 4.69028 3.3281004 "Belgium" "BE2" 3122059 3970053.5 5.134692 3.25513 "Belgium" "BE3" 3051593 3953864 4.7217956 3.309789 "Bulgaria" "BG31" 2360773.3 5440434 5.358757 1.9232876 "Bulgaria" "BG32" 2366455.5 5581033 5.441341 2.101523 "Bulgaria" "BG33" 2413181.8 5716947 5.718487 1.855372 end
I would like to create new observations that consist of every possible combination of pairs of regions within a country. Additionally, I want the explanatory variables of those newly created region pairs (ideology, demosat) to take on the difference in values between those two regions and - on the basis of the lat-long variables - also create a new variable that contains the geographical distance between those two regions in km for each pair. Is something like that possible?
I would greatly appreciate any help.
I'm currently using STATA 15.1 if that matters.
Kind regards,
Florian
Comment