prohibited medications check

Reply
N/A
Posts: 0

prohibited medications check

How to check programmatically if patient is taking medications more than 3 times a week? Patient ID, drug name and dates are known.

Thanks,
Eugene
Super Contributor
Super Contributor
Posts: 3,174

Re: prohibited medications check

Using DATE, create a WEEK_START date using the INTNX function. Then use a SAS PROC (SUMMARY, MEANS), as required, for aggregation and analysis.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

intnx function site:sas.com

Related DOC:
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm Message was edited by: sbb
N/A
Posts: 0

Re: prohibited medications check

Hi SBB,
please see data below, I need to have a list of ID/DRUG/DATE, that have taken the same drug more than 3 times a week. Thank you for you help.

ID DRUG DATE
100001 ADVIL 2010-03-25
100001 TILENOL 2010-04-08
100001 TILENOL 2010-04-10
100001 TILENOL 2010-04-12
100001 TILENOL 2010-04-14
100001 TILENOL 2010-04-28
100001 TILENOL 2010-05-01
100002 ADVIL 2010-04-01
100002 ADVIL 2010-04-09
100002 ADVIL 2010-04-10
100002 ADVIL 2010-04-12
100002 ADVIL 2010-04-14
100002 TILENOL 2010-04-28
100002 TILENOL 2010-05-01
Super Contributor
Super Contributor
Posts: 3,174

Re: prohibited medications check

Suggest you have a look at some SAS DOC on DATA step programming to get you started with learning SAS Base programming skills, my friend.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

data step programming site:sas.com

data step input data site:sas.com
Super Contributor
Super Contributor
Posts: 365

Re: prohibited medications check

Hello Evolod,

This is a possible solution to your problem. For the data you supplied all patients took less than 3 medications a week.

data a;
input ID 1-6 DRUG $ 8-14 DATE YYMMDD11.;
format date date7.;
datalines;
100001 ADVIL 2010-03-25
100001 TILENOL 2010-04-08
100001 TILENOL 2010-04-10
100001 TILENOL 2010-04-12
100001 TILENOL 2010-04-14
100001 TILENOL 2010-04-28
100001 TILENOL 2010-05-01
100002 ADVIL 2010-04-01
100002 ADVIL 2010-04-09
100002 ADVIL 2010-04-10
100002 ADVIL 2010-04-12
100002 ADVIL 2010-04-14
100002 TILENOL 2010-04-28
100002 TILENOL 2010-05-01
;
run;
/* Add Year, Week */;
data a1;
set a;
yr=YEAR(Date);
wk=WEEK(Date);
run;
/* Check if patient is taking meds more that 3 times a week */;
proc SQL;
create table r as
select ID, yr, wk, Count(*) as n,
case
when calculated n > 3 then ' >3'
else '<=3'
end as result
from a1
group by ID, yr, wk
;quit;

Sincerely,
SPR
Super Contributor
Super Contributor
Posts: 365

Re: prohibited medications check

Sorry, part of the code has been cut by forum software. It does not like apostrophes.
This is the last proc SQL:

proc SQL;
create table r as
select ID, yr, wk, Count(*) as n,
case
when calculated n > 3 then 'n GT 3'
else 'n LE 3'
end as result
from a1
group by ID, yr, wk
;quit;

SPR
SAS Super FREQ
Posts: 8,814

Re: prohibited medications check

Hi:
The issue is not the apostrophe, it is the < or > symbol. When you post to the forum using the posting mechanism, the < and > symbols, in particular, look like HTML tags. So you have to "hide" them from being mis-interpreted as HTML tags.

This previous forum posting:
http://support.sas.com/forums/thread.jspa?messageID=27609毙

explains how to use the &lt; and &gt; coding (for < and > respectively) to stop those symbols from being treated as HTML and truncating your posts.

cynthia
Occasional Contributor
Posts: 17

Re: prohibited medications check

This program will check before 7 days for each record's date and if the count is ge 3 then will print the patient id and drug name corresponding to it.

data pat;
input ID DRUG : $10. d_DATE : yymmdd10.;
format d_date date9.;
cards;
100001 ADVIL 2010-03-25
100001 TILENOL 2010-04-08
100001 TILENOL 2010-04-10
100001 TILENOL 2010-04-12
100001 TILENOL 2010-04-14
100001 TILENOL 2010-04-28
100001 TILENOL 2010-05-01
100002 ADVIL 2010-04-01
100002 ADVIL 2010-04-09
100002 ADVIL 2010-04-10
100002 ADVIL 2010-04-12
100002 ADVIL 2010-04-14
100002 TILENOL 2010-04-28
100002 TILENOL 2010-05-01
;run;



proc sql;
select unique id, drug
from
(
select
id,
drug,
d_date,
count(*) as cnt
from
(
select
a.*,
b.id as b_id,
b.drug as b_drug,
b.d_date as b_d_date
from pat a
join pat b on a.id=b.id
and a.drug=b.drug
and a.d_date between b.d_date-7 and b.d_date
) a
group by 1,2,3
having count(*)>=3
);
quit;
Ask a Question
Discussion stats
  • 7 replies
  • 619 views
  • 0 likes
  • 5 in conversation