Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with merge on a map?

    Hi, I'm very new to stata and I'm struggling to make a map.
    the code i've made is this:

    ssc install spmap
    ssc install shp2dta
    ssc install mif2dta

    cd "/Users/joseph/Documents/Econometrics/Stata data"

    shp2dta using Municipios_2009, database(mexdb) coordinates(mexcoord) genid(id)

    use mexdb.dta

    describe

    gen loc_code= CVE_ENT+ CVE_MUN
    destring loc_code, replace

    merge 1:1 loc_code using "totalhomicides.dta"
    drop merge

    spmap totalhomicides using mexcoord, id(id) fcolor(Blues)


    everything is fine until i get to "merge 1:1 loc_code using "totalhomicides.dta" then it says that the variable "loc_code" can't be found even though i thought i've just generated it.

    Any help would be really appreciated sorry if this is a bad question i'm really new to stata and dont know what Ive done wrong.

    Thank you

  • #2
    Originally posted by Joseph Vallely View Post
    everything is fine until i get to "merge 1:1 loc_code using "totalhomicides.dta" then it says that the variable "loc_code" can't be found even though i thought i've just generated it.
    Have you confirmed that it is present in "totalhomicides.dta"?

    Code:
    use "totalhomicides.dta"
    dataex in 1/5

    Comment

    Working...
    X