Dear Statalisters,
I have the following problem: I have data on international conflicts in which the variable side_a takes the form of "Government of country". If there are multiple countries involved these are only separated by a comma, e.g. "Government of India, Government of Nepal". I would like to see which countries were involved in wars in a given year.
I have to local macros, one representing the ISO3 country codes and one representing the country names, named listscode and listcountry.
There are two loops I am currently running: The code looks like this:
Of course what this does is return a 1 for all variables if any country is involved in a war. What I want it to do is basically look at table/matrice of country codes and country names, and if it finds a country name in the variable side_a, change the value of the variable representing the country code to 1. I have looked around the local and macro help files but did not find a solution of connecting two local macro lists like this, or storing a matrice, where I could write code that looks for one column, and than refers to the second column. Really happy for any help!
I hope I explained myself reasonably well.
Thanks in advance!
Kindest regards
Robert
I have the following problem: I have data on international conflicts in which the variable side_a takes the form of "Government of country". If there are multiple countries involved these are only separated by a comma, e.g. "Government of India, Government of Nepal". I would like to see which countries were involved in wars in a given year.
I have to local macros, one representing the ISO3 country codes and one representing the country names, named listscode and listcountry.
There are two loops I am currently running: The code looks like this:
Code:
foreach scode of local listscode{
gen `scode'=.
}
local varlist ZWE ZMB ZAF YEM XTX XKX WSM WLF VUT VNM VIR VGB VEN VCT VAT UZB USA URY UMI UKR UGA TZA TWN TUV TUR TUN TTO TON TLS TKM TKL TJK THA TGO TCD TCA SYR SYC SXM SWZ SWE SVN SVK SUR STP SSD SRB SPM SOM SMR SLV SLE SLB SJM SHN SGS SGP SEN SDN SAU RWA RUS ROU REU QAT PYF PSE PRY PRT PRK PRI POL PNG PLW PHL PER PCN PAN PAK OMN NZL NRU NPL NOR NLD NIU NIC NGA NFK NER NCL NAM MYT MYS MWI MUS MTQ MSR MRT MOZ MNP MNG MNE MMR MLT MLI MKD MHL MEX MDV MDG MDA MCO MAR MAF MAC LVA LUX LTU LSO LKA LIE LCA LBY LBR LBN LAO KWT KOR KNA KIR KHM KGZ KEN KAZ JPN JOR JEY JAM ITA ISR ISL IRQ IRN IRL IOT IND IMN IDN HUN HTI HRV HND HMD HKG GUY GUM GUF GTM GRL GRD GRC GNQ GNB GMB GLP GIN GIB GHA GGY GEO GBR GAB FSM FRO FRA FLK FJI FIN ETH EST ESP ESH ERI EGY ECU DZA DOM DNK DMA DJI DEU CZE CYP CYM CXR CUW CUB CRI CPV COM COL COK COG COD CMR CIV CHN CHL CHE CCK CAN CAF BWA BVT BTN BRN BRB BRA BOL BMU BLZ BLR BLM BIH BHS BHR BGR BGD BFA BES BEN BEL BDI AZE AUT AUS ATG ATF ATA ASM ARM ARG ARE AND ALB ALA AIA AGO AFG ABW
//soweit so gut
foreach var of local varlist {
foreach country of local listcountry{
replace `var'=1 if strpos(side_a, `"`country'"')
}
}
I hope I explained myself reasonably well.
Thanks in advance!
Kindest regards
Robert

Comment