BookmarkSubscribeRSS Feed
NewUsrStat
Lapis Lazuli | Level 10

Hi guys, 

suppose to have the following dataset (dataset1):

 

ID_patient              Drug            date_prescription           

      a1                     D_A                 21AUG20

      a2                     D_B                10SEP21

      a3                     D_A                 21AUG20

      a3                     D_A                17SEP20

      a4                     D_C                13MAY19         

      a4                     D_D                10MAR20

      a5                      D_X                09DEC22

      a5                      D_F                21DEC22

 

 

 

and another dataset (dataset2) with a selection from the first: 

 

ID_patient              Drug            date_prescription           

      a1                     D_A                21AUG20

      a2                     D_B               10SEP21

      a3                     D_A                21AUG20

      a4                     D_C               13MAY19         

 

The selection is based on the first prescription (looking at date_prescription) of drugs: D_A, D_B, D_C.

Now what I just would like to do is simply match the IDs and consequently the date_prescription from the second dataset to the first one and check if, based on the selected date (date_prescription) from the second dataset, the patient has no prescriptions of any of the D_A, D_B and D_C, in the 6 months before the date_prescription of the second dataset.

Note that the same patient must take only the same drug (but this comes with the selection of the second dataset). A patient from dataset 2 that takes D_A but in the previous 6 months D_B is not admitted.

 

 

Desired output:

ID_patient              Prescription_6months_before

      a1                                  no

      a2                                  no         

      a3                                  no                   

      a4                                  no             

 

 

 

 

 

Can anyone help me please? 

 

Thank you in advance

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

Please show us the desired output.

--
Paige Miller