Announcement

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

  • Creating spmap but getting r(459); Variable ID specified in option id() does not uniquely identify the observations

    I have a data set on India (India.dta) that includes location names at various levels, e.g. state, county, village. I want to map the data onto a state-level map of India but am running into problems when I try and map it. This is the code I have used so far:

    - Download map function -
    ssc install spmap
    ssc install shp2dta
    ssc install mif2dta
    - Dowload Map of India-
    Unzip file
    Will be using .dbf and .shp file
    -Go to Stata Command-
    shp2dta using indiastates.shp, database(indiastatesdb) coordinates(indiastatescoord) genid(ID) gencentroids(india) replace
    - Open indiastatesdb.dta-
    merge 1:m ID using India.dta

    Then when I try and run the map function:
    spmap using indiastatescoord.dta, id(ID)
    or
    spmap Total using "indiastatescoord.dta", id(ID)
    The following error comes up: r(459); Variable ID specified in option id() does not uniquely identify the observations

    Does anyone know how to solve this? Would be so greatly appreciated!!!

    Thank you (:

  • #2
    Code:
    merge 1:m ID using India.dta
    The 1:m merge on ID is creating multiple entries of ID and that's why you're seeing that error.

    Comment


    • #3
      I know this has been a bit, but you need the ID variable to missing for all but the first observation of a polygon (g ID2 = ID if _X==.)

      Comment

      Working...
      X