Announcement

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

  • quick merge question

    Hello!

    I am trying to merge 2 data sets, one for rainfall and one for temperature. Both have information of Longitude, Latitude, Date and rainfall (obs per grid) and obviously one temp and one rainfall. there is no unique identifier, what is a goodw ay to merge them? I tried joinby but given the size of the data-sets it crashes my pc (and I am restricted to using stata).

    the idea is then after having them merged, using geodist againts a database with longitude and latitude data on districts.. to drop any grid more than 100k away from the district points..

    Much help appreciated

  • #2
    Have you tried -merge 1:1 longitude latitude date- for this? If the two files match up on these three variables, that is the correct approach. If they don't, then I don't know what to tell you.

    Comment


    • #3
      Thank you Clyde,

      What actually worked is the command cross

      cross using "district_crosswalksmall.dta"
      geodist centroid_latitude centroid_longitude latitude longitude, gen (d) sphere
      drop if d > 100

      and now i have the data base I needed - if you dont minda follow up>

      i am trying to get the weighted daily average of rainfall with an end result being a yearly panel for every district. I created the weight (weight = inverse of distance squared) - and I am to use collapse -

      collapse (mean) temperature [xweight= weight], by (district id, year)

      i am not sure of what type of weight I should use (thats why I typed xweight), and specifically, would this give me a weighted daily average temperaturefor a district level daily dataset from 2009 to 2013

      Comment


      • #4
        I experimented a little and this gave me yearly averages,

        collapse (mean) temperature [xweight= weight], by (district id, year)
        so, I added the date variable and used aweights

        collapse (firstnm) statename districtname (mean) temperature [aweight= weight], by (district id, edate, year)

        Comment

        Working...
        X