BookmarkSubscribeRSS Feed
joreoh
Calcite | Level 5

I'm working on dispensed medication data. The variables in this data set are sold date, daily supply, daily dose, calculated medication end date, and cluster means the dispense was continuous without gap being >=15 days. If the last medication ending date was > 15 days apart from another opioids medication dispense date, the new cluster started. 

 

solddtrxsupdosemed_end_dtcluster
09/10/2009162009/26/20091
10/02/200924510/4/2009 1
10/06/20096690.9112/11/2009 1
10/12/20091620010/28/2009 1

10/21/2009

1262.511/2/2009 1
11/03/200933181.8212/6/2009 1
11/12/200924511/14/2009 1
11/12/20091620011/28/2009 1
12/04/200933181.821/6/2010 1
12/14/2009251281/8/2010 1
12/17/200924512/19/20091
01/15/20105451/20/20102
02//18/201025903/15/20103

 

I'd like to separate the overlapping records into new observations to get a data set that looks like

t0doset1New daily doseCluster
10-Sep-092009/26/20092001
2-Oct-094510/4/2009451
6-Oct-0990.9110/11/200990.911
12-Oct-0920010/20/2009290.911
21-Oct-0962.510/28/2009353.411
10/29/2009 11/2/2009153.411
3-Nov-09181.8211/11/2009272.731
12-Nov-0920011/14/2009335.911
11/15/20091611/28/2009290.911
11/29/2020 12/3/2009272.731
4-Dec-09181.8212/6/2009454.551
12/7/2009 12/11/2009272.731
12/12/2009 12/13/2009181.821
14-Dec-092512/16/2009309.821
17-Dec-094512/19/2009354.821
20-Dec-09 1/6/2010309.821
1/7/2010 1/8/20101281
15-Jan-10 1/20/2010452
18-Feb-10 3/12/2010903

 

I was able to identify overlapping records using the lag function, but am not sure how to proceed.

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Please provide your input data as a SAS data step, and not as a screen capture. See here for instructions.

--
Paige Miller
joreoh
Calcite | Level 5
data test;
	infile datalines delimiter = ',';
	input solddt: date9. rxsup  dose  med_end_dt: date9. cluster ;
	format solddt yymmdd10. med_end_dt yymmdd10.;
	datalines;
	10sep2009, 16, 200, 26sep2009, 1
	02oct2009, 2, 45, 04oct2009, 1
	06oct2009, 66, 90.91, 11dec2009, 1
	12oct2009, 16, 200, 28oct2009, 1
	21oct2009, 12, 62.5, 02nov2009, 1
	03nov2009, 33, 181.82, 06dec2009, 1
	12nov2009, 2, 45, 14nov2009, 1
	12nov2009, 16, 200, 28nov2009, 1
	04dec2009, 33, 181.82, 06jan2010, 1
	14dec2009, 25, 128, 08jan2010, 1
	17dec2009, 2, 45, 09dec2009, 1
	15jan2010, 5, 45, 20jan2010, 2
	18feb2010, 25, 90, 15mar2010, 3
	;
run;

The input data is provided above. Thank you.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 567 views
  • 0 likes
  • 2 in conversation