Announcement

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

  • merging cross-section data with shape file Stata data set

    Dear All

    I have a cross-section data and I want to merge it with shapefile using a key variable 'district id'. My cross-section data has 119,018 observations. I am using m:1 merge, it does merge the data but after that, I cannot use any 'sp' command on my merged data set because it gives the error that "_ID does not uniquely identify the observation". I followed the steps given in the manual https://www.stata.com/manuals/spspset.pdf. If anyone can help solve this issue, would be great.
    Last edited by Mudassira Sarfraz; 06 Sep 2019, 15:37.

  • #2
    I am having the same problem! Did you find any solution?

    Comment


    • #3
      I used the following code

      Code:
       use "D:\Data\distt.dta", clear
      spset
      merge 1:m distt_id using "D:\Data\PSLM.dta"
      save D:\Data\map.dta", replace
      global geodata "_CX _CY Shape_Leng ADMIN_UNIT Shape_Le_1 Shape_Le_2 Shape_Area Center_X Center_y distt_id"
      preserve
      drop if _ID==.
      collapse (mean) flfp (first) $geodata , by(_ID) /* I wanted to create map for flfp district-wise, you may use your required variable */
      restore
      I hope it helps.

      Comment

      Working...
      X