BookmarkSubscribeRSS Feed
jdukes42
Calcite | Level 5

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

5 REPLIES 5
art297
Opal | Level 21

Jonathan,

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

Art

.

jdukes42
Calcite | Level 5

Art-

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

Jonathan

art297
Opal | Level 21

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

jdukes42
Calcite | Level 5

Art-

Thanks. I will take a look at this.

Jonathan

Ksharp
Super User

Not quit sure.

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

Ksharp

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1461 views
  • 1 like
  • 3 in conversation