- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
if you want "two days apart", change
dif(date) ne 1
into
dif(date) > 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
the rules you follow are not clear to me:
"If on Jan 15th, the same member gets another prescription for a 10 days, the value would still be 30 days. But if another member gets one prescription on Jan 1st for 30 days and another prescription on Jan 25th for 10 days the days streak would now be at 35 days"
With the rows 30 and 10 you create one time a row of 30 and the other time a row of 35, what's the trigger? is it a date other than the 15th of the month? and what is the rule, is it 30+10/2?
"If there was a gap of more than 2 days between prescriptions a new set of days would be created based on above algorithm."
Please clarify and provide an example
- Cheers -
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming I understood what you mean.
data have;
input MemberId Fill_date : mmddyy12. Days_supply_cnt;
format fill_date mmddyy10.;
cards;
12345 01/01/2017 30
12345 01/15/2017 10
12345 02/10/2017 60
23456 01/01/2017 30
23456 01/25/2017 10
23456 04/01/2017 90
;
run;
data temp;
set have;
do date=fill_date to fill_date+Days_supply_cnt-1;
output;
end;
keep memberid date;
format date mmddyy10.;
run;
proc sort data=temp out=temp1 nodupkey;
by memberid date;
run;
data temp2;
set temp1;
by memberid;
if first.memberid or dif(date) ne 1 then group+1;
run;
proc freq data=temp2 noprint;
table memberid*group/out=want list;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
MemberId . fill_date Group123456 . 21oct2017 . 1123456. 22oct2017 . 1123456 . 23oct2017 . 1123456 . 25oct2017 . 2123456 . 26oct2017 . 2123456 . 27oct2017 . 2123456 . 28oct2017 . 2123456 . 29oct2017 . 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
if you want "two days apart", change
dif(date) ne 1
into
dif(date) > 2