Announcement

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

  • creating observation pairs for analysis


    Hello,

    I'd like to create start of care/ discharge pairs for analysis. I can find these pairs by looking at the start of care date because discharges matched with a start of care will share the same start of care date. I'd like to only keep existing pairs and then randomly select from the pairs. So in the sample data below, I would be trying to keep rows 1,2, 3,4, 7,8,9,10. what would be the most efficient way to do this?
    Thanks very much in advance for your help.


    row id Start of care date Discharge date Assessment type Assessment#
    1 1 01.20.16 . Start of care 1
    2 1 01.20.16 03.15.16 Discharge_type2 2
    3 2 12.03.16 . Start of care 1
    4 2 12.03.16 12.25.16 Disharge_type1 2
    5 2 05.20.16 . Start of care 3
    6 3 12.20.16 . Start of care 1
    7 4 06.05.16 . Start of care 1
    8 4 06.05.16 07.10.16 Discharge_type2 2
    9 4 09.12.16 Start of care 3
    10 4 09.12.16 11.20.16 Discharge_type3 4


  • #2

    Code:
    egen tokeep = max(discharge_date < .) , by(id start_date)
    will return 1 if there's a non-missing discharge date and 0 otherwise.

    count(discharge_date) as an egen function counts non-missing values.

    Comment


    • #3
      Thank you very much!

      Comment

      Working...
      X