Announcement

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

  • Merging issue with using data since the variables cannot uniquely identify observations

    Hello, This is my master data. My master is repeated cross section.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float year double county
    2001 10093
    2001 10093
    2001 10003
    2001 10003
    2002 10093
    2002 10093
    2002 10003
    2002 10003
    2002 10003
    2002 10001
    2003 10001
    2003 10001
    2003 10003
    2003 10003
    end

    This is my using data. My plan is to have a panel using data but the error message something else which I'll post after posting the sample using data below.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(year county)
    2000  1003
    2000  1097
    2000  1129
    2000  6001
    2000  6005
    2000  6009
    2000  6013
    2000  6041
    2000  6055
    2000  6059
    2000  6067
    2000  6077
    2000  6081
    2000  6085
    2000  6087
    2000  6095
    2000  6099
    2002 10001
    2002 10003
    2002 11001
    2002 12003
    2002 12007
    2002 12011
    2002 12015
    2002 12019
    end
    So when I'm merging master with the using data by the following command

    Code:
     merge m:1 year county using "trade.dta", keep(master match) nogen
    I get this error message

    Code:
     merge m:1 year county using "trade.dta", keep(master match) nogen
    (variable year was int, now float to accommodate using data's
           values)
    (variable county1 was float, now double to accommodate using
           data's values)
    variables year county do not uniquely identify observations in
        the using data
    r(459);
    
    end of do-file
    
    r(459);
    The issue is when I'm using the dataex command I don't see any repeated observation based on -dataex year county- command. But, after using the xtset and isid command I get the following information for my using data:

    Code:
     isid year county
    variables year and county should never be missing
    r(459);
    
    xtset year county
    
    Panel variable: year (unbalanced)
     Time variable: county, 1003 to 55133, but with gaps
             Delta: 1 unit
    May you kindly what problem in using data is causing the merging problem issue with the master data? Because the error clearly says while merging variables year county do not uniquely identify observations in
    the using data

  • #2
    In my using data I had some observations for which the value of county was missing. Therefore , I was having the problem. After fixing that merging was successful with master data.

    Comment


    • #3
      Thank you for closing the thread by posting the solution you arrived at. Future readers will benefit from that.

      Comment


      • #4
        Happy to do so ! This is the least I could do given that how gracious statalist community has been to me over time

        Comment

        Working...
        X