I'm trying to compute and incidence case based on test_1. So an incident case will be a positive test_1 and if and ID has multiple positive test_1, they only need to be counted as incident case if there's at least a 90 days period between the last positive. See the attached sample data.

Thanks,

David

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int(ID date) str8(test_1 test_2)
1000 22281 "negative" "negative"
1000 22295 "positive" "positive"
1000 22310 "negative" "positive"
1000 22326 "negative" "positive"
1000 22339 "negative" "positive"
1000 22353 "negative" "positive"
1000 22368 "positive" "positive"
1000 22380 "negative" "negative"
1000 22400 "negative" "negative"
1000 22385 "negative" "negative"
1000 22400 "positive" "positive"
1000 22415 "positive" "positive"
1001 22281 "negative" "positive"
1001 22295 "negative" "positive"
1001 22310 "negative" "negative"
1001 22326 "negative" "negative"
1001 22339 "negative" "negative"
1001 22353 "negative" "negative"
1001 22368 "negative" "negative"
1004 22281 "negative" "negative"
1004 22295 "negative" "negative"
1004 22310 "negative" "negative"
1004 22326 "negative" "negative"
1004 22339 "negative" "negative"
1004 22353 "negative" "negative"
1004 22368 "negative" "negative"
1004 22380 "negative" "negative"
1004 22400 "negative" "negative"
1004 22385 "negative" "negative"
1004 22400 "negative" "negative"
1005 22281 "positive" "positive"
1005 22295 "negative" "positive"
1005 22310 "negative" "positive"
1005 22326 "negative" "positive"
1005 22339 "negative" "positive"
1005 22353 "negative" "positive"
1005 22368 "negative" "positive"
1005 22380 "negative" "positive"
1010 22281 "positive" "negative"
1010 22295 "positive" "positive"
1010 22310 "positive" "positive"
1010 22326 "negative" "positive"
1010 22339 "negative" "positive"
1010 22353 "negative" "positive"
1010 22368 "negative" "positive"
1010 22380 "negative" "positive"
1010 22400 "negative" "positive"
1010 22385 "negative" "positive"
1010 22400 "positive" "positive"
1010 22415 "negative" "positive"
1010 22430 "negative" "positive"
end
format %tdnn/dd/CCYY date