Announcement

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

  • Merge datasets based on a range of a variable

    Hi Statalist,

    This is my first post but I have found this forum invaluable in the past.

    Hopefully a simple question from me.

    I am doing a study on trauma patients. We are looking at whether receiving blood prior to being admitted to a trauma center has any benefit to patients.

    The data from this study comes in two datasets that I am trying to merge

    Dataset1 contains informations on injury scores and co-mobidities
    Dataset2 contains information on whether the patients received a pre-hospital blood transfusion.

    Both datasets have 3 common variables that I am trying to merge with. These are Age, Sex and date of injury (or DOIJ as the variable in stata).

    Therefore the code I should use to merge these datasets seems simple

    Code:
    use Dataset1
    merge 1:1 Age Sex DOIJ using Dataset2
    However, patients may get a blood transfusion the day before they actually arrive in hospital (ie injury happened just before midnight so they receive the transfusion at 11pm and then arrive at hospital at 1am the next day.

    Is there a way I can merge my dataset using a range of dates for DOIJ.
    Note I have changed all dates to stata format.

    Thanks in advance

    Dilshan

  • #2
    probably the easiest way is to use the user-written -rangejoin- command; use -search- or -findit- to locate and install

    Comment


    • #3
      Hi Rich,

      Thanks for the prompt reply.

      I did come across that.

      I will have a look at it and give it a go.

      Cheers,

      Dilshan

      Comment

      Working...
      X