This code is still not working, I tried this and this is result i am getting . data test_epi_rules ; format StartDate2 new_startdate new_enddate mmddyy10. ; set _02_pt_regimen ; by PatientID ; StartDate2 = StartDate ; test=CEIL(INTCK('MONTH',StartDate,EndDate)/6) ; if first.PatientID and (EndDate - StartDate) ge 180 then do ; do i=1 to CEIL(INTCK('MONTH',StartDate,EndDate)/6) ; new_startdate=StartDate2; new_enddate=sum(StartDate2,180); StartDate2= sum(StartDate2,181); if new_enddate>EndDate then new_enddate=sum(new_startdate,180) ; output; end; end; else do ; new_startdate = StartDate ; new_enddate = sum(new_startdate,180) ; output ; end ; run; /*4406*/ Obs StartDate2 new_startdate new_enddate PatientID LineName last_visit death_date MetDiagnosisDate BirthYear age VisitDate StartDate EndDate test i1234567891011121314151617181920 02/01/2016 02/01/2016 07/30/2016 F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 02/11/2016 . 08/18/2015 1950 66 02/09/2016 02/01/2016 02/11/2016 0 . 02/16/2016 08/19/2015 02/15/2016 F002F4C07392F FOLFIRINOX 05/11/2016 06/15/2016 08/03/2015 1958 57 08/19/2015 08/19/2015 04/05/2016 2 1 08/15/2016 02/16/2016 08/14/2016 F002F4C07392F FOLFIRINOX 05/11/2016 06/15/2016 08/03/2015 1958 57 08/19/2015 08/19/2015 04/05/2016 2 2 04/06/2016 04/06/2016 10/03/2016 F002F4C07392F FOLFIRINOX 05/11/2016 06/15/2016 08/03/2015 1958 57 08/19/2015 04/06/2016 05/11/2016 1 . 05/28/2017 11/28/2016 05/27/2017 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 03/07/2018 . 07/24/2015 1947 69 12/05/2016 11/28/2016 08/21/2017 2 1 11/25/2017 05/28/2017 11/24/2017 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 03/07/2018 . 07/24/2015 1947 69 12/05/2016 11/28/2016 08/21/2017 2 2 08/22/2017 08/22/2017 02/18/2018 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 03/07/2018 . 07/24/2015 1947 69 12/05/2016 08/22/2017 03/07/2018 2 . 01/20/2017 01/20/2017 07/19/2017 F003E7ADEB2F8 Gemcitabine,Paclitaxel Protein-Bound 02/03/2017 02/15/2017 01/13/2017 1955 62 01/20/2017 01/20/2017 02/03/2017 1 . 07/12/2017 07/12/2017 01/08/2018 F006A77E4CDB0 FOLFIRINOX 12/07/2017 12/15/2017 07/10/2017 1969 48 07/12/2017 07/12/2017 08/27/2017 1 . 08/28/2017 08/28/2017 02/24/2018 F007499692F0D FOLFIRINOX 03/26/2018 . 07/28/2017 1961 56 08/28/2017 08/28/2017 10/31/2017 1 . 11/01/2017 11/01/2017 04/30/2018 F007499692F0D FOLFIRINOX 03/26/2018 . 07/28/2017 1961 56 08/28/2017 11/01/2017 03/26/2018 1 . 04/17/2016 10/19/2015 04/16/2016 F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 05/09/2016 07/15/2016 10/14/2015 1952 63 10/19/2015 10/19/2015 05/03/2016 2 1 10/15/2016 04/17/2016 10/14/2016 F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 05/09/2016 07/15/2016 10/14/2015 1952 63 10/19/2015 10/19/2015 05/03/2016 2 2 05/04/2016 05/04/2016 10/31/2016 F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 05/09/2016 07/15/2016 10/14/2015 1952 63 10/19/2015 05/04/2016 05/09/2016 0 . 09/21/2016 09/21/2016 03/20/2017 F00E0ED1D3143 FOLFIRINOX 03/27/2018 . 09/13/2016 1955 61 09/21/2016 09/21/2016 01/02/2017 1 . 06/09/2016 06/09/2016 12/06/2016 F00F92CD2DB8C FOLFOX 06/23/2016 07/15/2016 05/19/2016 1940 76 06/09/2016 06/09/2016 06/23/2016 0 . 08/04/2015 08/04/2015 01/31/2016 F01147636BCCA Gemcitabine,Paclitaxel Protein-Bound 12/14/2015 12/15/2015 09/19/2014 1954 61 08/04/2015 08/04/2015 11/03/2015 1 . 11/04/2015 11/04/2015 05/02/2016 F01147636BCCA Gemcitabine,Paclitaxel Protein-Bound 12/14/2015 12/15/2015 09/19/2014 1954 61 08/04/2015 11/04/2015 12/14/2015 1 . 07/01/2015 07/01/2015 12/28/2015 F012DC0F325EF Gemcitabine,Paclitaxel Protein-Bound 07/15/2015 08/15/2015 06/18/2014 1938 76 07/10/2014 07/01/2015 07/15/2015 0 . 03/09/2017 03/09/2017 09/05/2017 F01550BF09F41 Gemcitabine,Paclitaxel Protein-Bound 05/11/2017 06/15/2017 02/24/2017 1954 63 03/09/2017 03/09/2017 05/11/2017 1 . from this raw data ; Obs PatientID LineName last_visit death_date MetDiagnosisDate BirthYear age VisitDate StartDate EndDate12345678910 F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 02/11/2016 . 08/18/2015 1950 66 02/09/2016 02/01/2016 02/11/2016 F002F4C07392F FOLFIRINOX 05/11/2016 06/15/2016 08/03/2015 1958 57 08/19/2015 08/19/2015 04/05/2016 F002F4C07392F FOLFIRINOX 05/11/2016 06/15/2016 08/03/2015 1958 57 08/19/2015 04/06/2016 05/11/2016 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 03/07/2018 . 07/24/2015 1947 69 12/05/2016 11/28/2016 08/21/2017 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 03/07/2018 . 07/24/2015 1947 69 12/05/2016 08/22/2017 03/07/2018 F003E7ADEB2F8 Gemcitabine,Paclitaxel Protein-Bound 02/03/2017 02/15/2017 01/13/2017 1955 62 01/20/2017 01/20/2017 02/03/2017 F006A77E4CDB0 FOLFIRINOX 12/07/2017 12/15/2017 07/10/2017 1969 48 07/12/2017 07/12/2017 08/27/2017 F007499692F0D FOLFIRINOX 03/26/2018 . 07/28/2017 1961 56 08/28/2017 08/28/2017 10/31/2017 F007499692F0D FOLFIRINOX 03/26/2018 . 07/28/2017 1961 56 08/28/2017 11/01/2017 03/26/2018 F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 05/09/2016 07/15/2016 10/14/2015 1952 63 10/19/2015 10/19/2015 05/03/2016 for claim F002F4C07392F i should be getting only 2 observations because the new_enddate for that patient is more than the actual end date,, that means the second claim is already covered. i shjould not be getting three observations. and also for claim F00314B361B6A i am getting 4 whereas the new_enddate for this is 11/24/2017 and the next new_startdate is 08/22/2017 whereas it should be 11/25/2017.
... View more