Announcement

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

  • Merging paneldata

    Dear Statalisters,
    I am new with Stata (Version 15). I am conducting a gravity model on trade volumes. I am trying to merge two datasets by using the repsective options (m:1) - but in vain.The data sources look like:
    data in memory

    data on disk:

    I have been trying to combine both files via the Stata-Code:
    . merge m:1 exporter year using "GDP_exporter.dta"
    Prior to the merge-command, I have sorted for exporter and year.
    This does not work as I receive the following error "variables exporter year do not uniquely identify observations in the using data". I've got m observations/ combinations in the memory-file and 1 in the disk-file?
    I really appreciate your support. Thanks in advance.
    Best,
    Christoph


  • #2
    It looks like you tried to screenshot the data and those screenshots got eaten by the forum software. You should probably just sample the data and post it with a code tag. There are instructions in the FAQ. Also, as a matter of formatting, you should use the code tags for lines of what is technically code like:
    Code:
     merge m:1 exporter year using "GDP_exporter.dta"
    You should really just use GDP_exporter and then check whether the observations are really unique to exporter and year. There's a command from SSC called unique that you can use, but the simplest thing is just to type
    Code:
     duplicates report exporter year
    and check that there are no duplicates. Also, if you think the data should be unique, often times the data has missing values which throw people off.

    Comment


    • #3
      Thanks a lot! It has been a good and effective advice to concentrate on GDP_exporter only. Your help is much appreciated. Thanks and best, Christoph

      Comment

      Working...
      X