Announcement

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

  • Error in Grand Merge "variable hhcode does not uniquely identify observations in the using data"

    Dear Sir/Ma'am,
    I am using PSLM Data, ie, Pakistan Social & Living Standards Measurement. I have merged two data sets as I require an asset score of each household. I have also merged two other data sets as I need the combined information regarding each household. Now for a grand merge of these two merged data sets I am getting an error "variable hhcode does not uniquely identify observations in the using data". I tried 1:1 merge 1:m and m:1 but this message appears. FYI, PSLM data is cross sectional. Plus the above two merged data sets have been sorted with hhcode.

    Please advice and guide me. Thanks!
    My code is reproduced below:
    /*** Merging asset_score with the merged dataset of plist_1 and sec_e ***/

    clear

    set more off

    /*** To record coding and output ***/

    cap log close
    log using "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\grand_merge_plist_1_sec_e_asset_score.log", replace

    /*** Step Ia: Sort asset_score.dta by hhcode ***/
    use "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\asset_score.dta", clear
    sort hhcode
    save "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\sorted_asset_score",replace


    /*** Step Ib: Sort merged_plist_1_sec_e.dta by hhcode ***/
    use "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\merged_plist_1_sec_e.dta", clear

    sort hhcode
    save "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\sorted_ merged_plist_1_sec_e.dta ",replace

    /*** Step II: Merge asset_score.dta to merged_plist_1_sec_e.dta ***/
    merge m:1 hhcode using "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\sorted_asset_score", generate(grand_merge)

    save "D:\Data\Siddiqua\MS ECO\Dissertation\Econometric Analysis\PSLM 2012-13data in stata\grand_merge.dta", replace

    /*** End the program ***/
    log close
    exit

  • #2
    I suggest that you check for duplicates. Even high quality datasets can have problems like this.

    Code:
    help duplicates

    Comment


    • #3
      Thank you so much sir!

      Comment


      • #4
        Siddiqua Alibhai Could you please email me your do.file i am using the same data set and at the stage of merging aaajku @ gmail

        Comment

        Working...
        X