Hi, I am working on the project and stuck at this point. I have a data with id, start date, end date for prescribed drug, drug as below. This is the list of treatment days for certain drug for each patient. I need to keep the sequence of prescribed drug. The data 'have' is like ID start_date end_date drug ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 2003-01-01 2003-01-28 A 1 2003-02-01 2003-03-01 A 1 2003-03-15 2003-03-31 A 1 2003-04-11 2003-04-30 B 1 2003-06-01 2003-07-28 B 1 2003-07-31 2003-08-15 B 1 2003-09-01 2003-09-28 A 1 2003-10-01 2003-11-28 A 2 2005-04-30 2005-06-01 C ........ ..... ... if I use the code like proc sql;
create table want as
select id, min(start_date) as start, max(end_date) as end, drug
from have
group by drug;
quit; I would have a data like id start_date end_date drug ~~~~~~~~~~~~~~~~~~~~~~~~~ 1 2003-01-01 2003-11-28 A 1 2003-04-11 2003-08-15 B this is wrong. The output I want is id start_date end_date drug ~~~~~~~~~~~~~~~~~~~~~~~~~ 1 2003-01-01 2003-03-31 A 1 2003-04-11 2003-08-15 B 1 2003-09-01 2003-11-28 A ........ ..... I need to keep the sequence of drug and get the min. date and max. date for each sequence of drug. anybody know what to do? I tried first.last. retain..... etc.. i am really stuck here.. please help me out!!
... View more