Announcement

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

  • merging panel data - merge or joinby?

    hello! I am looking to merge two datasets to end with coherent district-level daily dataset from 2009-2013 with temperature, rainfall, and total rainfall variables.

    - the first dataset "finalrainfall" has the following shape

    Year Edate District_id State_name District_name dailymeanrainfall dailytotalrainfall

    - the second dataset "finaltemp" has the following shape

    Year Edate District_id State_name District_name Weightedavertemp

    I initially tried using the merge command, but I got the error message given that there variables I used werent unique identifiers (merge 1:1 district_id year using "finalrainfall"

    I have tried using also joinby - joinby district_id year using "finalrainfall" -

    are the results given in this case by joinby equivalet to what merge would have provided?

  • #2
    Mike:
    as we do not know your datasets, it is difficul to check whether you got waht you expected with -joinby-.
    That said, a temptative hint would be to give -merge- one more try with the most comprehensive set of key variables which are common to both datasets:
    Code:
    merge 1:1 Year Edate District_id State_name District_name
    and see what happens.

    As an aside, whenever it comes to -append-, -merge- and -joinby- storing a copy of the original datasets is highly advisable.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Mike:
      as we do not know your datasets, it is difficul to check whether you got waht you expected with -joinby-.
      That said, a temptative hint would be to give -merge- one more try with the most comprehensive set of key variables which are common to both datasets:
      Code:
      merge 1:1 Year Edate District_id State_name District_name
      and see what happens.

      As an aside, whenever it comes to -append-, -merge- and -joinby- storing a copy of the original datasets is highly advisable.
      Thank you very much Carlo,

      I used the merge 1:1 option with the variables you stated and I indeed got it to work, with the difference that it now included data that was being removed before (unmatched tem/raionfall data)

      Comment


      • #4
        Mike:
        -merge- outcome comes with a -_merge- indicator that can give you some further details about what went right/wrong with your -merge- procedure.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment

        Working...
        X