I need to identify patients that got med1 and med2 on the same day, or within 7 days. I made a variable that identified if a patient got two or more prescriptions on the same date:
duplicates tag patID date, gen (sameday)
But that new variable also gave me some results of patients who received two types of med1, not both med1 and med2, as I am interested in.
|
Code:
|
|||
| * Example generated by -dataex-. To install: ssc install dataex | |||
| clear | |||
| input long patID float(date med1 med2) byte sameday | |||
| 76632 19493 1 . 0 | |||
| 76779 21626 1 . 1 | |||
| 76779 21626 . 1 1 | |||
| 76779 21781 1 . 0 | |||
| 76779 21896 1 . 0 | |||
| 76804 21509 . 1 0 | |||
| 76806 20612 . 1 0 | |||
| 76806 20685 . 1 0 | |||
| 76837 19620 1 . 1 | |||
| 76837 19620 1 . 1 | |||
| 76837 19709 1 . 2 | |||
| 76837 19709 1 . 2 | |||
| 76837 19709 . 1 2 | |||
| 76911 20368 1 . 0 | |||
| 76911 20403 . 1 0 | |||
| 76911 20458 . 1 0 | |||
| 76911 20511 . 1 0 | |||
| 76911 20581 . 1 0 | |||
| 77072 19852 1 . 0 | |||
| 77072 19950 1 . 0 | |||
| 77072 20485 . 1 1 | |||
| 77072 20485 1 . 1 | |||
| 77072 20544 . 1 0 | |||
| 77072 20850 1 . 0 | |||
| 77072 21565 . 1 1 | |||
| 77072 21565 1 . 1 | |||
| 77072 21595 . 1 0 | |||
| 77072 21862 . 1 0 | |||
| 77072 21875 . 1 0 | |||
| 77601 21867 1 . 1 | |||
| 77601 21867 1 . 1 | |||
| 77636 19463 1 . 1 | |||
| 77636 19463 1 . 1 | |||
| 77636 19600 1 . 1 | |||
| 77636 19600 1 . 1 | |||
| 77636 19884 1 . 0 | |||
| 77636 19977 1 . 0 | |||
| 77636 20123 1 . 0 | |||
| 77636 20301 1 . 0 | |||
| 77636 20593 1 . 0 | |||
| 77636 20678 1 . 0 | |||
| 77745 21265 . 1 0 | |||
| 77745 21803 . 1 0 | |||
| 77755 20982 1 . 0 | |||
| end | |||
| format %tdCCYY-NN-DD date | |||
0 Response to Same date or within 7 days, within two variables
Post a Comment