Hello everybody,
I am trying to reproduce the share of Covid-19 vaccinated population per US county. However, while I do have observations for around 3000 counties, the map is showing data only for a few of them. I do not understand the source of this issue and as I have been stuck with this problem for several hours, any help would be greatly appreciated!
I am trying to reproduce the share of Covid-19 vaccinated population per US county. However, while I do have observations for around 3000 counties, the map is showing data only for a few of them. I do not understand the source of this issue and as I have been stuck with this problem for several hours, any help would be greatly appreciated!
Code:
clear shp2dta using ".\Data - no vaxxers study\spmap example\cb_2016_us_county_500k.shp", database(counties) coordinates(cntycoord) genid(id) replace //NB counties and cntycoord dta files are created on the same do file's folder !!! shp2dta using ".\Data - no vaxxers study\spmap example\cb_2016_us_state_500k.shp", /// database(states) coordinates(statecoord) genid(id) replace *Drop the observations from unincorporated territories, islands, Hawaii, and Alaska. use statecoord, clear drop if _ID == 2 drop if _ID == 11 drop if _ID == 34 drop if _ID == 54 drop if _ID == 33 drop if _ID == 56 drop if _ID == 55 save "statecoord.dta", replace . use ".\Data - no vaxxers study\anti-vaxxer dataset - temporary.dta", replace gen STATEFP = substr(fips,1,2) gen COUNTYFP = substr(fips,3,6) order STATEFP COUNTYFP, after(fips) merge m:1 STATEFP COUNTYFP using "counties.dta" *Keep only the matched observations - observations in both data sets that are matched by GEOID. keep if _merge == 3 ssc install palettes, replace // for color palettes ssc install colrspace, replace // for expanding the color base gen rel_dem2020 = votesDEMOCRAT2020 label var rel_dem2020 "Relative Dem. votes (2020)" gen dem_share2020 = votesDEMOCRAT2020/totalvotes2020 label var dem_share2020 "Dem. votes share (2020)" order rel_dem2020 dem_share2020, after(rep_share2020) * Figure 3.a Map for vaccination rate // For all amps, I consider percentiles for break points colorpalette Blues, select(2 3 5 7 8 ) ipolate(5) nograph qui spmap series_complete_pop_pct using cntycoord if date1=="31may2022" & state!="Alaska" & state != "Hawaii", id(id) fcolor(`r(p)') /// clnumber(5) ocolor(Greys) polygon(data(statecoord.dta) ocolor(black)) legend(pos(6) row(2) ring(1) symx(*.75) symy(*.75) forcesize) /// name(map_vacc, replace) clmethod(custom) clbreaks (11 40 47 53 60 100) legorder(hilo) title("a) Fully vaccinated people against" "Covid-19 (%)", /// size(medsmall)) // legtitle("Fully vaccinated people (%)") /// graph export ".\Anti-vaxxer study - material\AVUSA output\- Figure 3a USA maps vaccination and votes.png", as(png) replace
Comment