DATA Step, Macro, Functions and more

treatment lines

Reply
Contributor
Posts: 20

treatment lines

Hi ,

 

This is what my dataset looks like right now :

 

obs Patient IDLineNameStartDateEndDate
1F000678A98792Gemcitabine,Paclitaxel Protein-Bound2/1/20162/11/2016
2F002F4C07392FFOLFIRINOX8/19/2015  04/05/2016
3F002F4C07392FGemcitabine,Paclitaxel Protein-Bound4/6/20165/11/2016
4F00314B361B6AFOLFOX8/22/2017 03/07/2018
5F00314B361B6AGemcitabine10/12/201511/27/2016
6F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/2016 08/21/2017

 

But i want to see somehting like this :

 

 

The rule is that each treatment line should not be longer than the 6 months, and if it is then we break it down and mark the EndDate as StartDate +180 and the new treatment starts form StartDate  +181. if there are more one type of treatment for the same patent in the duration of the 6 months, the earliest one is taken.

..

 

How to write this ?

 

obsPatient IDLineNameStartDateEndDate
1F000678A98792Gemcitabine,Paclitaxel Protein-Bound2/1/20162/11/2016
2F002F4C07392FFOLFIRINOX8/19/20151/19/2016
3F002F4C07392FFOLFIRINOX1/20/20164/5/2016
4F002F4C07392FGemcitabine,Paclitaxel Protein-Bound4/6/20165/11/2016
5F00314B361B6AFOLFOX8/22/20171/22/2017
6F00314B361B6AFOLFOX1/23/20173/7/2018
7F00314B361B6AGemcitabine10/12/20153/12/2016
8F00314B361B6AGemcitabine3/13/20168/13/2016
9F00314B361B6AGemcitabine8/14/201611/27/2016
10F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/20164/28/2016
11F00314B361B6AGemcitabine,Paclitaxel Protein-Bound4/29/20169/29/2016
12F00314B361B6AGemcitabine,Paclitaxel Protein-Bound9/30/20163/2/2017
13F00314B361B6AGemcitabine,Paclitaxel Protein-Bound3/3/20168/3/2017
14F00314B361B6AGemcitabine,Paclitaxel Protein-Bound8/4/20178/21/2017
Super Contributor
Posts: 478

Re: treatment lines

Hi,

 

I don't think your output matches the requirement you mentioned.


@manya92 wrote:

Hi ,

 

This is what my dataset looks like right now :

 

obs  Patient ID LineName StartDate EndDate
1 F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 2/1/2016 2/11/2016
2 F002F4C07392F FOLFIRINOX 8/19/2015   04/05/2016
3 F002F4C07392F Gemcitabine,Paclitaxel Protein-Bound 4/6/2016 5/11/2016
4 F00314B361B6A FOLFOX 8/22/2017  03/07/2018
5 F00314B361B6A Gemcitabine 10/12/2015 11/27/2016
6 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 11/28/2016  08/21/2017

 

But i want to see somehting like this :

 

 

The rule is that each treatment line should not be longer than the 6 months, and if it is then we break it down and mark the EndDate as StartDate +180 and the new treatment starts form StartDate  +181. if there are more one type of treatment for the same patent in the duration of the 6 months, the earliest one is taken.

..

 

How to write this ?

 

obs Patient ID LineName StartDate EndDate
1 F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 2/1/2016 2/11/2016
2 F002F4C07392F FOLFIRINOX 8/19/2015 1/19/2016
3 F002F4C07392F FOLFIRINOX 1/20/2016 4/5/2016
4 F002F4C07392F Gemcitabine,Paclitaxel Protein-Bound 4/6/2016 5/11/2016
5 F00314B361B6A FOLFOX 8/22/2017 1/22/2017
6 F00314B361B6A FOLFOX 1/23/2017 3/7/2018
7 F00314B361B6A Gemcitabine 10/12/2015 3/12/2016
8 F00314B361B6A Gemcitabine 3/13/2016 8/13/2016
9 F00314B361B6A Gemcitabine 8/14/2016 11/27/2016
10 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 11/28/2016 4/28/2016
11 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 4/29/2016 9/29/2016
12 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 9/30/2016 3/2/2017
13 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 3/3/2016 8/3/2017
14 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 8/4/2017 8/21/2017

How can the end data be past start date here.

 

Here is my approach on how I understood your requirement, if not you can change modify the code to your requirement. 

DATA have;
format StartDate EndDate mmddyy10.;
infile datalines dlm=',' dsd missover;
input PatientID :$15.	LineName :$50. StartDate :mmddyy10. EndDate :mmddyy10.;
datalines;
F000678A98792,Gemcitabine Paclitaxel Protein-Bound,2/1/2016,2/11/2016
F002F4C07392F,FOLFIRINOX,8/19/2015,04/05/2016
F002F4C07392F,Gemcitabine Paclitaxel Protein-Bound,4/6/2016,5/11/2016
F00314B361B6A,FOLFOX,8/22/2017,03/07/2018
F00314B361B6A,Gemcitabine,10/12/2015,11/27/2016
F00314B361B6A,Gemcitabine Paclitaxel Protein-Bound,11/28/2016,08/21/2017
;
run;

data want ;
format New_SartDate New_EndDate mmddyy10.;
set have;
if INTCK('MONTH',StartDate,EndDate)>6 then do;
		do i=1 to CEIL(INTCK('MONTH',StartDate,EndDate)/6) ;
				New_SartDate=StartDate;
				New_EndDate=StartDate+180;
				StartDate=StartDate+181;
				if New_EndDate>EndDate then New_EndDate=EndDate;
				output;
				end;
			end;
else output;
run;

 

Thanks,
Suryakiran
Contributor SJN
Contributor
Posts: 24

Re: treatment lines

Posted in reply to SuryaKiran

can you explain me this logic.Why dividing by 6?

do i=1 to CEIL(INTCK('MONTH',StartDate,EndDate)/6) ;

 

Contributor
Posts: 20

Re: treatment lines

I wrote this code , but it doesnt seem to work completely :

 

data want ;
set have ;
by PatientID ;
StartDate2 = StartDate ;
retain StartDate2 ;
format new_enddate new_startdate StartDate2 mmddyy10. ;
if (EndDate - StartDate) ge 180
then do ;
new_startdate = StartDate2 ;
new_enddate = sum(new_startdate,180);
StartDate2 = StartDate +181 ;
end;
else if (EndDate - StartDate2) lt 180 then do;
new_enddate = sum(StartDate2,180) ;
new_startdate = StartDate2 ;
end ;
run ;

 

RAW DATA

 Obs PatientID LineName StartDate EndDate1234567891011121314151617181920

F000678A98792Gemcitabine,Paclitaxel Protein-Bound02/01/201602/11/2016
F002F4C07392FFOLFIRINOX08/19/201504/05/2016
F002F4C07392FGemcitabine,Paclitaxel Protein-Bound04/06/201605/11/2016
F00314B361B6AGemcitabine10/12/201511/27/2016
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/201608/21/2017
F00314B361B6AFOLFOX08/22/201703/07/2018
F003E7ADEB2F8Gemcitabine,Paclitaxel Protein-Bound01/20/201702/03/2017
F006A77E4CDB0FOLFIRINOX07/12/201708/27/2017
F006A77E4CDB0Pembrolizumab08/28/201712/07/2017
F007499692F0DFOLFIRINOX08/28/201710/31/2017
F007499692F0DGemcitabine,Paclitaxel Protein-Bound11/01/201703/26/2018
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/2017
F00C081DC6BC4Gemcitabine,Paclitaxel Protein-Bound02/17/201708/13/2017
F00C081DC6BC4Capecitabine,Gemcitabine08/14/201711/09/2017
F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound10/19/201505/03/2016
F00CC20661EE3FOLFIRINOX05/04/201605/09/2016
F00E0ED1D3143FOLFIRINOX09/21/201601/02/2017
F00E0ED1D3143Fluorouracil,Gemcitabine,Irinotecan,Leucovorin,Oxaliplatin,Paclitaxel Protein-Bound01/03/201703/27/2018
F00F92CD2DB8CFOLFOX06/09/201606/23/2016
F01147636BCCAGemcitabine,Paclitaxel Protein-Bound08/04/201511/03/2015

EPISODE RULE

 

 

I want to see the values in StartDate2 to appear in new_startdate .. and tehn add 180 to them to get the new_enddate..

 

 Obs PatientID LineName StartDate EndDate new_startdate new_enddate StartDate21234567891011121314151617181920

F000678A98792Gemcitabine,Paclitaxel Protein-Bound02/01/201602/11/201602/01/201607/30/201602/01/2016
F002F4C07392FFOLFIRINOX08/19/201504/05/201602/16/201602/15/201608/19/2015
F002F4C07392FGemcitabine,Paclitaxel Protein-Bound04/06/201605/11/201604/06/201610/03/201604/06/2016
F00314B361B6AGemcitabine10/12/201511/27/201604/10/201604/09/201610/12/2015
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/201608/21/201705/28/201705/27/201711/28/2016
F00314B361B6AFOLFOX08/22/201703/07/201802/19/201802/18/201808/22/2017
F003E7ADEB2F8Gemcitabine,Paclitaxel Protein-Bound01/20/201702/03/201701/20/201707/19/201701/20/2017
F006A77E4CDB0FOLFIRINOX07/12/201708/27/201707/12/201701/08/201807/12/2017
F006A77E4CDB0Pembrolizumab08/28/201712/07/201708/28/201702/24/201808/28/2017
F007499692F0DFOLFIRINOX08/28/201710/31/201708/28/201702/24/201808/28/2017
F007499692F0DGemcitabine,Paclitaxel Protein-Bound11/01/201703/26/201811/01/201704/30/201811/01/2017
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/201708/12/201408/11/201402/12/2014
F00C081DC6BC4Gemcitabine,Paclitaxel Protein-Bound02/17/201708/13/201702/17/201708/16/201702/17/2017
F00C081DC6BC4Capecitabine,Gemcitabine08/14/201711/09/201708/14/201702/10/201808/14/2017
F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound10/19/201505/03/201604/17/201604/16/201610/19/2015
F00CC20661EE3FOLFIRINOX05/04/201605/09/201605/04/201610/31/201605/04/2016
F00E0ED1D3143FOLFIRINOX09/21/201601/02/201709/21/201603/20/201709/21/2016
F00E0ED1D3143Fluorouracil,Gemcitabine,Irinotecan,Leucovorin,Oxaliplatin,Paclitaxel Protein-Bound01/03/201703/27/201807/03/201707/02/201701/03/2017
F00F92CD2DB8CFOLFOX06/09/201606/23/201606/09/201612/06/201606/09/2016
F01147636BCCAGemcitabine,Paclitaxel Protein-Bound08/04/201511/03/201508/04/201501/31/201608/04/2015

I want it to look like this :

obsPatient IDLineNameStartDateEndDate
1F000678A98792Gemcitabine,Paclitaxel Protein-Bound2/1/20167/1/2016
2F002F4C07392FFOLFIRINOX8/19/20151/19/2016
3F002F4C07392FFOLFIRINOX1/20/20166/20/2016
4F002F4C07392FGemcitabine,Paclitaxel Protein-Bound4/6/20165/11/2016
5F00314B361B6AFOLFOX8/22/20171/22/2017
6F00314B361B6AFOLFOX1/23/20173/7/2018
7F00314B361B6AGemcitabine10/12/20153/12/2016
8F00314B361B6AGemcitabine3/13/20168/13/2016
9F00314B361B6AGemcitabine8/14/201611/27/2016
10F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/20164/28/2016
11F00314B361B6AGemcitabine,Paclitaxel Protein-Bound4/29/20169/29/2016
12F00314B361B6AGemcitabine,Paclitaxel Protein-Bound9/30/20163/2/2017
13F00314B361B6AGemcitabine,Paclitaxel Protein-Bound3/3/20168/3/2017
14F00314B361B6AGemcitabine,Paclitaxel Protein-Bound8/4/20178/21/2017
Super Contributor
Posts: 478

Re: treatment lines

[ Edited ]

@manya92 wrote:

I wrote this code , but it doesnt seem to work completely :

 

data want ;
set have ;
by PatientID ;
StartDate2 = StartDate ;
retain StartDate2 ;
format new_enddate new_startdate StartDate2 mmddyy10. ;
if (EndDate - StartDate) ge 180
then do ;
new_startdate = StartDate2 ;
new_enddate = sum(new_startdate,180);
StartDate2 = StartDate +181 ;
end;
else if (EndDate - StartDate2) lt 180 then do;
new_enddate = sum(StartDate2,180) ;
new_startdate = StartDate2 ;
end ;
run ;

 

RAW DATA

 Obs PatientID LineName StartDate EndDate1234567891011121314151617181920

F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 02/01/2016 02/11/2016
F002F4C07392F FOLFIRINOX 08/19/2015 04/05/2016
F002F4C07392F Gemcitabine,Paclitaxel Protein-Bound 04/06/2016 05/11/2016
F00314B361B6A Gemcitabine 10/12/2015 11/27/2016
F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 11/28/2016 08/21/2017
F00314B361B6A FOLFOX 08/22/2017 03/07/2018
F003E7ADEB2F8 Gemcitabine,Paclitaxel Protein-Bound 01/20/2017 02/03/2017
F006A77E4CDB0 FOLFIRINOX 07/12/2017 08/27/2017
F006A77E4CDB0 Pembrolizumab 08/28/2017 12/07/2017
F007499692F0D FOLFIRINOX 08/28/2017 10/31/2017
F007499692F0D Gemcitabine,Paclitaxel Protein-Bound 11/01/2017 03/26/2018
F0080CAE5E872 Gemcitabine,Paclitaxel Protein-Bound 02/12/2014 04/19/2017
F00C081DC6BC4 Gemcitabine,Paclitaxel Protein-Bound 02/17/2017 08/13/2017
F00C081DC6BC4 Capecitabine,Gemcitabine 08/14/2017 11/09/2017
F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 10/19/2015 05/03/2016
F00CC20661EE3 FOLFIRINOX 05/04/2016 05/09/2016
F00E0ED1D3143 FOLFIRINOX 09/21/2016 01/02/2017
F00E0ED1D3143 Fluorouracil,Gemcitabine,Irinotecan,Leucovorin,Oxaliplatin,Paclitaxel Protein-Bound 01/03/2017 03/27/2018
F00F92CD2DB8C FOLFOX 06/09/2016 06/23/2016
F01147636BCCA Gemcitabine,Paclitaxel Protein-Bound 08/04/2015 11/03/2015

EPISODE RULE

 

 

I want to see the values in StartDate2 to appear in new_startdate .. and tehn add 180 to them to get the new_enddate..

 

 Obs PatientID LineName StartDate EndDate new_startdate new_enddate StartDate21234567891011121314151617181920

F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 02/01/2016 02/11/2016 02/01/2016 07/30/2016 02/01/2016
F002F4C07392F FOLFIRINOX 08/19/2015 04/05/2016 02/16/2016 02/15/2016 08/19/2015
F002F4C07392F Gemcitabine,Paclitaxel Protein-Bound 04/06/2016 05/11/2016 04/06/2016 10/03/2016 04/06/2016
F00314B361B6A Gemcitabine 10/12/2015 11/27/2016 04/10/2016 04/09/2016 10/12/2015
F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 11/28/2016 08/21/2017 05/28/2017 05/27/2017 11/28/2016
F00314B361B6A FOLFOX 08/22/2017 03/07/2018 02/19/2018 02/18/2018 08/22/2017
F003E7ADEB2F8 Gemcitabine,Paclitaxel Protein-Bound 01/20/2017 02/03/2017 01/20/2017 07/19/2017 01/20/2017
F006A77E4CDB0 FOLFIRINOX 07/12/2017 08/27/2017 07/12/2017 01/08/2018 07/12/2017
F006A77E4CDB0 Pembrolizumab 08/28/2017 12/07/2017 08/28/2017 02/24/2018 08/28/2017
F007499692F0D FOLFIRINOX 08/28/2017 10/31/2017 08/28/2017 02/24/2018 08/28/2017
F007499692F0D Gemcitabine,Paclitaxel Protein-Bound 11/01/2017 03/26/2018 11/01/2017 04/30/2018 11/01/2017
F0080CAE5E872 Gemcitabine,Paclitaxel Protein-Bound 02/12/2014 04/19/2017 08/12/2014 08/11/2014 02/12/2014
F00C081DC6BC4 Gemcitabine,Paclitaxel Protein-Bound 02/17/2017 08/13/2017 02/17/2017 08/16/2017 02/17/2017
F00C081DC6BC4 Capecitabine,Gemcitabine 08/14/2017 11/09/2017 08/14/2017 02/10/2018 08/14/2017
F00CC20661EE3 Gemcitabine,Paclitaxel Protein-Bound 10/19/2015 05/03/2016 04/17/2016 04/16/2016 10/19/2015
F00CC20661EE3 FOLFIRINOX 05/04/2016 05/09/2016 05/04/2016 10/31/2016 05/04/2016
F00E0ED1D3143 FOLFIRINOX 09/21/2016 01/02/2017 09/21/2016 03/20/2017 09/21/2016
F00E0ED1D3143 Fluorouracil,Gemcitabine,Irinotecan,Leucovorin,Oxaliplatin,Paclitaxel Protein-Bound 01/03/2017 03/27/2018 07/03/2017 07/02/2017 01/03/2017
F00F92CD2DB8C FOLFOX 06/09/2016 06/23/2016 06/09/2016 12/06/2016 06/09/2016
F01147636BCCA Gemcitabine,Paclitaxel Protein-Bound 08/04/2015 11/03/2015 08/04/2015 01/31/2016 08/04/2015

I want it to look like this :

obs Patient ID LineName StartDate EndDate
1 F000678A98792 Gemcitabine,Paclitaxel Protein-Bound 2/1/2016 7/1/2016
2 F002F4C07392F FOLFIRINOX 8/19/2015 1/19/2016
3 F002F4C07392F FOLFIRINOX 1/20/2016 6/20/2016
4 F002F4C07392F Gemcitabine,Paclitaxel Protein-Bound 4/6/2016 5/11/2016
5 F00314B361B6A FOLFOX 8/22/2017 1/22/2017
6 F00314B361B6A FOLFOX 1/23/2017 3/7/2018
7 F00314B361B6A Gemcitabine 10/12/2015 3/12/2016
8 F00314B361B6A Gemcitabine 3/13/2016 8/13/2016
9 F00314B361B6A Gemcitabine 8/14/2016 11/27/2016
10 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 11/28/2016 4/28/2016
11 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 4/29/2016 9/29/2016
12 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 9/30/2016 3/2/2017
13 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 3/3/2016 8/3/2017
14 F00314B361B6A Gemcitabine,Paclitaxel Protein-Bound 8/4/2017 8/21/2017

Can you please explain how can you record 10 here has an end date past your start date. Did you try the logic I provided. 

 

In my previous code the DO LOOP will check how many sets of 180 days between startdate and enddate exists. 

For example consider this record: F002F4C07392F,FOLFIRINOX,8/19/2015,04/05/2016
here number of months b/w startdate and enddate are 8(INTCK('MONTH',StartDate,EndDate)) months. So for this situation it need two
records for this record with continuous start end dates.
Need:
New_SartDate New_EndDate PatientID LineName
08/19/2015 02/15/2016 F002F4C07392F FOLFIRINOX
02/16/2016 04/05/2016 F002F4C07392F FOLFIRINOX

For this you need a do loop to iterate 2(CEIL(INTCK('MONTH',StartDate,EndDate)/6)) times with output and necessary conditions.

NOTE: This is just an approach and you can change the logic as per your requirement.

Thanks,
Suryakiran
Contributor
Posts: 20

Re: treatment lines

Posted in reply to SuryaKiran
I tried you logic but it worked only half way
Contributor
Posts: 20

Re: treatment lines

Posted in reply to SuryaKiran

This is what i got

 Obs PatientID LineName StartDate EndDate new_startdate new_enddate StartDate21234567891011121314151617181920

F000678A98792Gemcitabine,Paclitaxel Protein-Bound02/01/201602/11/2016..02/01/2016
F002F4C07392FFOLFIRINOX08/19/201504/05/201608/19/201502/15/201602/16/2016
F002F4C07392FFOLFIRINOX08/19/201504/05/201602/16/201604/05/201608/15/2016
F002F4C07392FGemcitabine,Paclitaxel Protein-Bound04/06/201605/11/2016..04/06/2016
F00314B361B6AGemcitabine10/12/201511/27/201610/12/201504/09/201604/10/2016
F00314B361B6AGemcitabine10/12/201511/27/201604/10/201610/07/201610/08/2016
F00314B361B6AGemcitabine10/12/201511/27/201610/08/201611/27/201604/07/2017
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/201608/21/201711/28/201605/27/201705/28/2017
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound11/28/201608/21/201705/28/201708/21/201711/25/2017
F00314B361B6AFOLFOX08/22/201703/07/201808/22/201702/18/201802/19/2018
F00314B361B6AFOLFOX08/22/201703/07/201802/19/201803/07/201808/19/2018
F003E7ADEB2F8Gemcitabine,Paclitaxel Protein-Bound01/20/201702/03/2017..01/20/2017
F006A77E4CDB0FOLFIRINOX07/12/201708/27/2017..07/12/2017
F006A77E4CDB0Pembrolizumab08/28/201712/07/2017..08/28/2017
F007499692F0DFOLFIRINOX08/28/201710/31/2017..08/28/2017
F007499692F0DGemcitabine,Paclitaxel Protein-Bound11/01/201703/26/2018..11/01/2017
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/201702/12/201408/11/201408/12/2014
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/201708/12/201402/08/201502/09/2015
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/201702/09/201508/08/201508/09/2015
F0080CAE5E872Gemcitabine,Paclitaxel Protein-Bound02/12/201404/19/201708/09/201502/05/201602/06/2016

 

There are still missing vaules for new_startdate and new_enddate 

 

Super Contributor
Posts: 478

Re: treatment lines

If the difference is not greater than 6 months then you might get missing values. To avoid this at last add

 

IF missing(new_startdate) and missing(new_enddate) then DO;

new_startdate=startdate;

new_enddate=enddate;

end;

Thanks,
Suryakiran
Contributor
Posts: 20

Re: treatment lines

Posted in reply to SuryaKiran

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/201602/01/201607/30/2016F000678A98792Gemcitabine,Paclitaxel Protein-Bound02/11/2016.08/18/201519506602/09/201602/01/201602/11/20160.
02/16/201608/19/201502/15/2016F002F4C07392FFOLFIRINOX05/11/201606/15/201608/03/201519585708/19/201508/19/201504/05/201621
08/15/201602/16/201608/14/2016F002F4C07392FFOLFIRINOX05/11/201606/15/201608/03/201519585708/19/201508/19/201504/05/201622
04/06/201604/06/201610/03/2016F002F4C07392FFOLFIRINOX05/11/201606/15/201608/03/201519585708/19/201504/06/201605/11/20161.
05/28/201711/28/201605/27/2017F00314B361B6AGemcitabine,Paclitaxel Protein-Bound03/07/2018.07/24/201519476912/05/201611/28/201608/21/201721
11/25/201705/28/201711/24/2017F00314B361B6AGemcitabine,Paclitaxel Protein-Bound03/07/2018.07/24/201519476912/05/201611/28/201608/21/201722
08/22/201708/22/201702/18/2018F00314B361B6AGemcitabine,Paclitaxel Protein-Bound03/07/2018.07/24/201519476912/05/201608/22/201703/07/20182.
01/20/201701/20/201707/19/2017F003E7ADEB2F8Gemcitabine,Paclitaxel Protein-Bound02/03/201702/15/201701/13/201719556201/20/201701/20/201702/03/20171.
07/12/201707/12/201701/08/2018F006A77E4CDB0FOLFIRINOX12/07/201712/15/201707/10/201719694807/12/201707/12/201708/27/20171.
08/28/201708/28/201702/24/2018F007499692F0DFOLFIRINOX03/26/2018.07/28/201719615608/28/201708/28/201710/31/20171.
11/01/201711/01/201704/30/2018F007499692F0DFOLFIRINOX03/26/2018.07/28/201719615608/28/201711/01/201703/26/20181.
04/17/201610/19/201504/16/2016F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound05/09/201607/15/201610/14/201519526310/19/201510/19/201505/03/201621
10/15/201604/17/201610/14/2016F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound05/09/201607/15/201610/14/201519526310/19/201510/19/201505/03/201622
05/04/201605/04/201610/31/2016F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound05/09/201607/15/201610/14/201519526310/19/201505/04/201605/09/20160.
09/21/201609/21/201603/20/2017F00E0ED1D3143FOLFIRINOX03/27/2018.09/13/201619556109/21/201609/21/201601/02/20171.
06/09/201606/09/201612/06/2016F00F92CD2DB8CFOLFOX06/23/201607/15/201605/19/201619407606/09/201606/09/201606/23/20160.
08/04/201508/04/201501/31/2016F01147636BCCAGemcitabine,Paclitaxel Protein-Bound12/14/201512/15/201509/19/201419546108/04/201508/04/201511/03/20151.
11/04/201511/04/201505/02/2016F01147636BCCAGemcitabine,Paclitaxel Protein-Bound12/14/201512/15/201509/19/201419546108/04/201511/04/201512/14/20151.
07/01/201507/01/201512/28/2015F012DC0F325EFGemcitabine,Paclitaxel Protein-Bound07/15/201508/15/201506/18/201419387607/10/201407/01/201507/15/20150.
03/09/201703/09/201709/05/2017F01550BF09F41Gemcitabine,Paclitaxel Protein-Bound05/11/201706/15/201702/24/201719546303/09/201703/09/201705/11/20171.

 

from this raw data ;

 Obs PatientID LineName last_visit death_date MetDiagnosisDate BirthYear age VisitDate StartDate EndDate12345678910

F000678A98792Gemcitabine,Paclitaxel Protein-Bound02/11/2016.08/18/201519506602/09/201602/01/201602/11/2016
F002F4C07392FFOLFIRINOX05/11/201606/15/201608/03/201519585708/19/201508/19/201504/05/2016
F002F4C07392FFOLFIRINOX05/11/201606/15/201608/03/201519585708/19/201504/06/201605/11/2016
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound03/07/2018.07/24/201519476912/05/201611/28/201608/21/2017
F00314B361B6AGemcitabine,Paclitaxel Protein-Bound03/07/2018.07/24/201519476912/05/201608/22/201703/07/2018
F003E7ADEB2F8Gemcitabine,Paclitaxel Protein-Bound02/03/201702/15/201701/13/201719556201/20/201701/20/201702/03/2017
F006A77E4CDB0FOLFIRINOX12/07/201712/15/201707/10/201719694807/12/201707/12/201708/27/2017
F007499692F0DFOLFIRINOX03/26/2018.07/28/201719615608/28/201708/28/201710/31/2017
F007499692F0DFOLFIRINOX03/26/2018.07/28/201719615608/28/201711/01/201703/26/2018
F00CC20661EE3Gemcitabine,Paclitaxel Protein-Bound05/09/201607/15/201610/14/201519526310/19/201510/19/201505/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. 

 

Ask a Question
Discussion stats
  • 8 replies
  • 170 views
  • 0 likes
  • 3 in conversation