DATA Step, Macro, Functions and more

Collapsing Consecutive Dates

Reply
Occasional Contributor
Posts: 11

Collapsing Consecutive Dates

Hi All,

I have a new question regarding collapsing consecutive dates.

For my study I am looking at antibiotic prescriptions. I have already determined the patients who would have been given a single primary antibiotic. However, now I have to address those individuals who would fall into the mixed therapy category. For these individuals I want to collapse the start and stop dates for antibiotics given on consecutive dates. In addition to collapsing to a single date, I need to retain the antibiotic given on those dates (see example below).

IDRX_1RX_2Start_1Start_2Stop_1Stop_2New_StartNew_StopNew_RX_1New_RX_2
1125/2/20015/3/20015/2/20015/3/20015/2/20015/3/200112
2135/2/20015/2/20015/2/20015/2/20015/2/20015/2/200113

However, not all individuals will have multiple treaments that can be collapsed into one set of consecutive dates. In those cases I need a data set that will look something like this

IDRX_1RX_2Start_1Start_2Stop_1Stop_2New_Start1New_Stop1New_Start2New_Stop2New_RX1_1New_RX1_2New_RX2_1New_RX2_2
3125/2/20015/10/20015/2/20015/19/20015/2/20015/2/20015/10/20015/19/200112

The overall data set has up to 8 different prescription (RX), start, and stop dates that have to be collapsed.

Thanks,

Jonathan

PROC Star
Posts: 7,467

Collapsing Consecutive Dates

Jonathan,

All of the dates in your example are from 2001.  What is the actual range of possible dates?

Art

.

Occasional Contributor
Posts: 11

Collapsing Consecutive Dates

Art-

The dates range from 2005 to 2010. Thanks again for your interest and help.

Jonathan

PROC Star
Posts: 7,467

Collapsing Consecutive Dates

Jonathan,

Take a look at this thread from SAS-L last year.  Two approaches are discussed/provided for capturing date ranges:

http://www.listserv.uga.edu/cgi-bin/wa?A2=ind1010E&L=sas-l&D=1&H=0&O=D&T=1&m=307534&P=4731

I would think that either approach could be modified to meet your needs.

Art

Occasional Contributor
Posts: 11

Collapsing Consecutive Dates

Art-

Thanks. I will take a look at this.

Jonathan

Super User
Posts: 10,018

Collapsing Consecutive Dates

Not quit sure.

What does your dataset look like and what output do you want?

Ksharp

Ask a Question
Discussion stats
  • 5 replies
  • 244 views
  • 1 like
  • 3 in conversation