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

  • Identifying two prescriptions within a variable length episode of care using a date variable in a long dataset

    Hello Statalisters,

    I have the following example long data set. I have matched together data on emergency contraception drugs (Levonelle/EllaOne) with another dataset on Progesterone Only Pill (Desogestrel). Prescriptions are usually made on the same day (e.g pseudoID ==3746), but in some cases the POP drugs may be prescribed up to 5 days later (e.g. pseudoID 166). Patients may also be prescribed emergency contraception in one month, and then POP several months data (e.g. pseudoID 214).

    I would like to first tag all observations which meet the criteria of pseudoID 166 (i.e. EC followed by POP prescribed between 1-5 days after the EC prescription). Then I would like to effectively do a 1:1 merge with them so that I can examine the characteristics of those prescribed both EC and POP in the same episode of care.

    With best wishes


    ----------------------- copy starting from the next line -----------------------
    * Example generated by -dataex-. To install: ssc install dataex
    input long pseudoID int Createdat str9 Drug str20 POP
     166 22228 "EllaOne" ""          
     166 22231 ""        "Desogestrel"
     214 22060 "EllaOne" ""          
     214 22215 ""        "Desogestrel"
    3476 22123 "EllaOne" ""          
    3476 22147 "EllaOne" ""          
    format %tdnn/dd/CCYY Createdat
    label values pseudoID pseudoID
    ------------------ copy up to and including the previous line ------------------

    Listed 6 out of 8736 observations