I have some panel data where individuals could receive multiple types of service in a given visit; thus my data is at the individual-service type level.
What I want to do, at the month level, is identify when someone returned to receive the exact same service within a couple months of the initial service.
So, if someone received Service A10 in January 2024, and then came back again in either February or March to receive Service A10 again, I'd want to just create a simple variable that flags the February/March "repeat" row as =1. What is the simplest way to accomplish this? Example data below. Thanks.
What I want to do, at the month level, is identify when someone returned to receive the exact same service within a couple months of the initial service.
So, if someone received Service A10 in January 2024, and then came back again in either February or March to receive Service A10 again, I'd want to just create a simple variable that flags the February/March "repeat" row as =1. What is the simplest way to accomplish this? Example data below. Thanks.
Code:
clear input str2 id str10 date str5 code str7 yr_month "01" "05 Jan 23" "100A" "2023m1" "01" "20 Jan 23" "100A" "2023m1" "01" "15 Feb 23" "405A" "2023m2" "01" "15 Mar 23" "100A" "2023m3" "01" "10 Apr 23" "25D5" "2023m4" "01" "25 May 23" "100A" "2023m5" "01" "15 May 23" "300C" "2023m5" "01" "20 Jun 23" "499" "2023m6" "01" "01 Jul 23" "205Z.4" "2023m7" "02" "01 Mar 23" "200B" "2023m3" "02" "05 Apr 23" "25D6" "2023m4" "02" "10 May 23" "400D" "2023m5" "02" "10 May 23" "500E" "2023m5" "02" "01 Jun 23" "20.OB" "2023m6" "03" "01 Jan 24" "300C" "2024m1" "03" "01 Feb 24" "300C" "2024m2" "03" "01 Apr 24" "25D8" "2024m4" end
Comment