One of the most common calculation used across all types of programming is determining a relative 'day' based on 2 date fields. In clinical trials the initial 'Study Day' is generally considered to begin at either randamization or dosing, thus assessments made prior to this starting point require a slight variation in the calculating in order to preserve the typical 'no day 0' concept.
SUGI proceedings10/054-2010.pdf |
if visdt > randdt >.z then stydy=visdt-randdt;
else stydt=visdt-randdt+1;
However, this is unnecessary, sine the 1-liner will suffice:
if visdt >.z & randdt >.z then stydy=visdt-randdt+(visdt>=randdt);
Thanks to Stephen for his code.
Here is the code I use from now to compute the study day.
if nmiss(visidt,randdt)=0 then stydy=visdt-randdt+(visdt>=randdt);