IDENTIFYING MOST RECENT DOSE DATE TIME FOR AN EVENT USING PROC SQL

IDENTIFYING MOST RECENT DOSE DATE TIME FOR AN EVENT USING PROC SQL

In a crossover design, a subject is treated for different treatment periods and received different treatments. In clinical trial a subject might experience an adverse event at any point of time. In order to identify, in which group the adverse event could be counted, the onset date need to compare across the treatment dates and will be counted under most recent treatment given.

The approach usually adopted for this is transposing the treatment date time values and compare it with the onset date. But if the treatment days are more in number, the comparison will be much complicated. Also if there are discontinued subjects in the study, this comparison may lead to a wrong conclusion.

Using SQL procedure of SAS, we can minimize the complications. This works by computing the max (dosedate) which is happened before the event.

data ex;

input SUBJID$ VISIT$ EXSTDTM :datetime20. TRT$;

format EXSTDTM datetime20.;

cards;

001 visit1 01SEP2014:11:30 A

001 visit2 06SEP2014:11:30 B

001 visit3 10SEP2014:11:30 C

001 visit4 . D

002 visit1 01SEP2014:11:30 B

002 visit2 06SEP2014:11:30 C

002 visit3 10SEP2014:11:30 D

002 visit4 12SEP2014:11:30 A

003 visit1 01SEP2014:11:30 C

003 visit2 . D

003 visit3 . A

003 visit4 . B

004 visit1 01SEP2014:11:30 D

004 visit2 06SEP2014:11:30 A

004 visit3 10SEP2014:11:30 B

004 visit4 12SEP2014:11:30 C

;
run;

data AE;

input SUBJID$ AETERM:$20. AESTDTM :datetime20.;

format AESTDTM datetime20.;

cards;

001 Nausea 06SEP2014:8:30

001 Fever 10SEP2014:12:45

001 Headache 13SEP2014:04:15

002 Fever 11SEP2014:06:30

003 Dizziness 02SEP2014:06:00

003 Vomitting 14SEP2014:12:00

004 Pain 09SEP2014:9:30
;
run;

proc sql noprint;

create table aetrt as

select ae.SUBJID, ae.AETERM, ae.AESTDTM, ex.TRT, ex.EXSTDTM as DOSEDTM_recent from ae, ex

where ae.SUBJID = ex.SUBJID

and ex.EXSTDTM = (select max(EXSTDTM)

from ex

where ae.SUBJID = ex.SUBJID

and (EXSTDTM <=AESTDTM )) ;
quit;
OUTPUT:

proc-sql

Post A Comment

Protected by WP Anti Spam