Announcement

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

  • Merging panel data with non panel data

    Is it possible to merge panel data (multiple observations for each individual) with data that isn't panel data (only one observation per individual)?
    I have tried to do so but get the error message that my identifier doesn't uniquely identify observations.
    So is it possible to merge these types of data together?

  • #2
    Yes. But only if the non-panel data set really has only one observation for each individual. When people encounter these error messages, it is overwhelmingly more often the case that the problem is with the non-panel data set than with the code they are using. If your non-panel data set is correct, it goes like this:*
    Code:
    use panel_data_set, clear
    merge m:1 individual_id_variable using non_panel_data_set
    Now, if this code produces an error message saying that the id variable doesn't uniquely identify observations in the using data, it means that your non_panel_data_set is not what you think it is: it does in fact contain multiple observations for at least some values of the id variable. This incorrect data set is by far the commonest cause of the kind of problem you are encountering; code errors are much less frequent.

    If that happens, you need to first find those offending values of the id variable:
    Code:
    use non_panel_data_set, clear
    duplicates tag id_variable, gen(flag)
    browse if flag
    Then you have to figure out how they got there and how to fix the data management so you can re-create that data set without the extra observations being there. The details of doing that, of course, depend on the specific situation, so I can't elaborate on them here.

    *It can also be done the other way around:
    Code:
    use non_panel_data_set, clear
    merge 1:m individual_id_variable using panel_data_set
    In the event that your non_panel_data_set is wrong, this time the message will say that individual_id_variable fails to identify unique observations in the master data.

    Comment

    Working...
    X