DATA Step, Macro, Functions and more

how do i identify if member had early re-fill

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

how do i identify if member had early re-fill

Hi,

I am looking to identify if a member had early refill and if so number days he filled early for the same combination of Drug and strength.

Mem_id DOS qty_disp days_supply Drug Strength
1001 01/18/2016 4 28 drug1 10 MCG/HR
1001 02/25/2016 4 14 drug1 5 MCG/HR
1001 03/24/2016 30 30 drug2 350 MG
1001 03/25/2016 4 28 drug1 10 MCG/HR
1001 04/05/2016 60 15 drug3 7.5-325MG
1001 05/12/2016 60 15 drug3 7.5-325MG
1001 01/18/2016 4 14 drug1 5 MCG/HR
1001 01/21/2016 120 30 drug4 10 MG
1002 01/21/2016 90 30 drug5 10 MG
1002 02/10/2016 90 30 drug5 10 MG
1002 02/18/2016 120 30 drug4 10 MG
1002 03/20/2016 120 30 drug4 10 MG
1002 03/20/2016 90 30 drug5 10 MG
1002 04/22/2016 90 30 drug5 10 MG
1002 04/22/2016 120 30 drug4 10 MG
1002 02/21/2016 40 5 drug3 7.5-325MG

 

output , i am looking for early refilled members with no. of days and drug combinations

mem_id drug stength eary_refill_days

1002 drug5 10MG 8

.

.

.

Thanks in advance for your your help


Accepted Solutions
Solution
‎05-23-2016 11:05 AM
PROC Star
Posts: 1,760

Re: how do i identify if member had early re-fill

Posted in reply to sasuser77

Indeed you are right. There was an error. This is better:

 


data WANT;
  set HAVE; 
  by MEM_ID DRUG STRENGTH DOS ;
  if ^first.STRENGTH & DOS-lag(DOS) < lag(DAYS_SUPPLY) *0.75 then output;
run;

View solution in original post


All Replies
Super User
Posts: 11,343

Re: how do i identify if member had early re-fill

Posted in reply to sasuser77

"Early" implies comparing two dates or times. Is DOS the date of the prescription or the date filled?

How would we know what is "early"?

 

Can you show from your example data which ones are "early"?

Occasional Contributor
Posts: 17

Re: how do i identify if member had early re-fill

Early implies a same combination drug and strength that is again filled before the refill_Due date(fill_dt + days_supply).

In my example i am considering below line no.10 as early re-fill

The durg5 first filled on 1/21/2016 and it was supposed to re-fill on or later 2/20/2016 (refill_due date)

where as here it is re-filled on 2/10/2016 that is 10 days earlier.

 

SnoMem_idDOS (fill_dt) qty_dispdays_supplyRefill_Due(fill_dt + days_supply)DrugStrength
1100101/18/201642802/15/2016drug110 MCG/HR
2100102/25/201641403/10/2016drug15 MCG/HR
3100103/24/2016303004/23/2016drug2350 MG
4100103/25/201642804/22/2016drug110 MCG/HR
5100104/05/2016601504/20/2016drug37.5-325MG
6100105/12/2016601505/27/2016drug37.5-325MG
7100101/18/201641402/01/2016drug15 MCG/HR
8100101/21/20161203002/20/2016drug410 MG
9100201/21/2016903002/20/2016drug510 MG
10100202/10/2016903003/11/2016drug510 MG
11100202/18/20161203003/19/2016drug410 MG
12100203/20/20161203004/19/2016drug410 MG
13100203/20/2016903004/19/2016drug510 MG
14100204/22/2016903005/22/2016drug510 MG
15100204/22/20161203005/22/2016drug410 MG
16100202/21/201640502/26/2016drug37.5-325MG
Super User
Posts: 11,343

Re: how do i identify if member had early re-fill

Posted in reply to sasuser77

Do you have a rule for how many days early is to be reported as early?

Occasional Contributor
Posts: 17

Re: how do i identify if member had early re-fill

Any re-fill before 75% of refill_due considered as early.

for a 30 days_supply drug with fill_dt 1/1/2016 and refill_due as 1/31/2016. Anything before 1/23/16 considered early refill.

PROC Star
Posts: 1,760

Re: how do i identify if member had early re-fill

[ Edited ]
Posted in reply to sasuser77

Like this?

 

 

data HAVE(index=(A=(MEM_ID DRUG STRENGTH DOS)));
input MEM_ID DOS mmddyy10. QTY_DISP DAYS_SUPPLY DRUG $ STRENGTH & $10.  ;
cards;
1001 01/18/2016 4 28 drug1 10 MCG/HR
1001 02/25/2016 4 14 drug1 5 MCG/HR
1001 03/24/2016 30 30 drug2 350 MG
1001 03/25/2016 4 28 drug1 10 MCG/HR
1001 04/05/2016 60 15 drug3 7.5-325MG
1001 05/12/2016 60 15 drug3 7.5-325MG
1001 01/18/2016 4 14 drug1 5 MCG/HR
1001 01/21/2016 120 30 drug4 10 MG
1002 01/21/2016 90 30 drug5 10 MG
1002 02/10/2016 90 30 drug5 10 MG
1002 02/18/2016 120 30 drug4 10 MG
1002 03/20/2016 120 30 drug4 10 MG
1002 03/20/2016 90 30 drug5 10 MG
1002 04/22/2016 90 30 drug5 10 MG
1002 04/22/2016 120 30 drug4 10 MG
1002 02/21/2016 40 5 drug3 7.5-325MG
run;

data WANT;
  set HAVE; 
  by MEM_ID DRUG STRENGTH DOS ;
  if ^first.STRENGTH & DOS-lag(DOS) < DAYS_SUPPLY *0.75 then output;
run;

 

 

Occasional Contributor
Posts: 17

Re: how do i identify if member had early re-fill

Thanks chris, This is exactly what i was looking for.

 

however, the code is also displaying unwanted data for below example

 

have

MEM_IDDOSQTY_DISPdays_supplyDrugStrengthrefill_due
100301/05/20164515Drug137.5-325MG01/20/2016
100302/06/20164515Drug137.5-325MG02/21/2016
100302/23/201618090Drug137.5-325MG05/23/2016
100305/10/201627090Drug137.5-325MG08/08/2016

 

want:

Below highlighted row shouldn't have been listed.

 

MEM_IDDOSQTY_DISPdays_supplyDrugStrengthrefill_duedays_early
10032/23/201618090Drug137.5-325MG5/23/201673
10035/10/201627090Drug137.5-325MG8/8/201613
Solution
‎05-23-2016 11:05 AM
PROC Star
Posts: 1,760

Re: how do i identify if member had early re-fill

Posted in reply to sasuser77

Indeed you are right. There was an error. This is better:

 


data WANT;
  set HAVE; 
  by MEM_ID DRUG STRENGTH DOS ;
  if ^first.STRENGTH & DOS-lag(DOS) < lag(DAYS_SUPPLY) *0.75 then output;
run;
Occasional Contributor
Posts: 17

Re: how do i identify if member had early re-fill

This is perfect. Thank you so much!

Super User
Posts: 10,041

Re: how do i identify if member had early re-fill

[ Edited ]
Posted in reply to sasuser77

Not sure whether the following code is what you are looking for .

 

 

 

 

data have;
input Mem_id DOS : mmddyy10. qty_disp days_supply Drug $ Strength & $20.;
Refill_Due=DOS+days_supply ;
format DOS Refill_Due mmddyy10.;
cards;
1001 01/18/2016 4 28 drug1 10 MCG/HR
1001 02/25/2016 4 14 drug1 5 MCG/HR
1001 03/24/2016 30 30 drug2 350 MG
1001 03/25/2016 4 28 drug1 10 MCG/HR
1001 04/05/2016 60 15 drug3 7.5-325MG
1001 05/12/2016 60 15 drug3 7.5-325MG
1001 01/18/2016 4 14 drug1 5 MCG/HR
1001 01/21/2016 120 30 drug4 10 MG
1002 01/21/2016 90 30 drug5 10 MG
1002 02/10/2016 90 30 drug5 10 MG
1002 02/18/2016 120 30 drug4 10 MG
1002 03/20/2016 120 30 drug4 10 MG
1002 03/20/2016 90 30 drug5 10 MG
1002 04/22/2016 90 30 drug5 10 MG
1002 04/22/2016 120 30 drug4 10 MG
1002 02/21/2016 40 5 drug3 7.5-325MG
;
run;
data want;
 array _DOS{99999} _temporary_;
 array _Refill_Due{99999} _temporary_;
 
n=0;
call missing(of _DOS{*} _Refill_Due{*});
do until(last.Strength);
 set have;
 by Mem_id Drug Strength notsorted;
 n+1;
 _DOS{n}=DOS;
 _Refill_Due{n}=Refill_Due; 
end;
 
do until(last.Strength);
 set have;
 by Mem_id Drug Strength notsorted;
 flag=0;
 do i=1 to n;
  if DOS<_DOS{i}<Refill_Due and Refill_Due<_Refill_Due{i} then do;
   flag=1;leave;
  end;
 end; 
 output;
end;
drop i n;
run;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 355 views
  • 0 likes
  • 4 in conversation