Hi,

I'm working with diagnostic labdata and I'd like to count how many times a person has been tested for disease X within a certain time frame (1 month).
Thus, I'd like to tag any test for the same disease within the same patient (id) that occurs within the set time frame.
My variable for date of test is a date variable (%dD_m_Y). My data contains 3 types of tests (A, B and C).

So, it would have to look like this:
ID TEST DATE TAG
1 A 1-jan-19 0
1 B 10-jan-19 0
1 A 1-mar-19 0
2 B 1-jan-19 0
2 B 10-jan-19 1

--> Only the last test gets tagged, because it's the only time that a second test gets done <1 month for the SAME disease in the SAME patient.
It's easy to count duplicates in terms of ID and TEST, but how do I incorporate the timeframe?

Thank you very much in advance!