Merging with a dose

(Author: Roland Rashleigh-Berry                                                                                Date: 28 Apr 2006)





Sometimes you need to merge in dose data with adverse events so you know what dose a subject was on when they had the adverse event. This dose data may have gaps with no dose and maybe overlaps for the stop date and the following start date. How you handle overlaps may vary from compound to compound. I wrote a macro for this because merrging on date ranges requires a knowledge of SQL that not all programmers have. You can view the macro below.
dosemerge

Do not use this macro blindly. You need to be aware that I am using rules in the macro to handle overlaps that may not be correct for the drug you are working on.
 
data dose;
  subj=1;sdate='01jan2002'd;edate='05jan2002'd;dose=4;output;
  subj=1;sdate='07jan2002'd;edate='14jan2002'd;dose=6;output;
  subj=1;sdate='14jan2002'd;edate='21jan2002'd;dose=0;output;
  subj=2;sdate='14jan2002'd;edate='21jan2002'd;dose=5;output;
  format sdate edate date9.;
run;

data ae;
  subj=1;onset='14jan2002'd;output;
  subj=2;onset='20jan2002'd;output;
  format onset date9.;
run;

%dosemerge(dsin=ae,dsout=ae2,subject=subj,date=onset,
dsdose=dose,dosestart=sdate,dosestop=edate,doselevel=dose,
fixoverlaps=yes);

data _null_;
  set ae2;
  put (_all_) (=);
run;

Some of the log output is shown below. Note that because of the way the macro handles overlaps by reducing the stop date of the previous dose, then subj=1 is assigned a zero dose for 14JAN2002.
 
18
19    data _null_;
20      set ae2;
21      put (_all_) (=);
22    run;

subj=1 onset=14JAN2002 dose=0
subj=2 onset=20JAN2002 dose=5
NOTE: There were 2 observations read from the data set WORK.AE2.
NOTE: DATA statement used:
      real time           0.00 seconds
      cpu time            0.00 seconds


 
 

Use the "Back" button of your browser to return to the previous page

contact the author


Check here for dose and related to data
Secure SFTP and FTPS provided by GoFTP FREE