Posts

Showing posts with the label One liner

STUDY 'DAY' CLCULATION (ONE-LINER)

Image
Recently I stumbled upon a SUGI-Paper  SAS 1-Liners by Stephen Hunt. I liked the way Stephen developed the 1-liner for   STUDY DAY calculation. Direct link: 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   When it comes to calculating such, some programmers opt to both with evaluating whether a visit date occurred on or /after randomization. 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); ...