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).
ID | RX_1 | RX_2 | Start_1 | Start_2 | Stop_1 | Stop_2 | New_Start | New_Stop | New_RX_1 | New_RX_2 |
1 | 1 | 2 | 5/2/2001 | 5/3/2001 | 5/2/2001 | 5/3/2001 | 5/2/2001 | 5/3/2001 | 1 | 2 |
2 | 1 | 3 | 5/2/2001 | 5/2/2001 | 5/2/2001 | 5/2/2001 | 5/2/2001 | 5/2/2001 | 1 | 3 |
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
ID | RX_1 | RX_2 | Start_1 | Start_2 | Stop_1 | Stop_2 | New_Start1 | New_Stop1 | New_Start2 | New_Stop2 | New_RX1_1 | New_RX1_2 | New_RX2_1 | New_RX2_2 |
3 | 1 | 2 | 5/2/2001 | 5/10/2001 | 5/2/2001 | 5/19/2001 | 5/2/2001 | 5/2/2001 | 5/10/2001 | 5/19/2001 | 1 | 2 |
The overall data set has up to 8 different prescription (RX), start, and stop dates that have to be collapsed.
Thanks,
Jonathan
Jonathan,
All of the dates in your example are from 2001. What is the actual range of possible dates?
Art
.
Art-
The dates range from 2005 to 2010. Thanks again for your interest and help.
Jonathan
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
Art-
Thanks. I will take a look at this.
Jonathan
Not quit sure.
What does your dataset look like and what output do you want?
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.