/* dtadd: Determine the future date given current date and the number of years, weeks, or days until yymmdd. */ program define dtadd version 2.1 if "%_*" == "" { di in red "invalid syntax -- see help dtadd" exit 198 } if substr("%_3",1,1)=="d" { mac def _3 "d" } else if substr("%_3",1,1)!="y" { dtadd } if _N != 0 { di in red "no; data in memory would be lost" exit 4 } quietly set obs 1 gen double DATE1=%_1 ftoe DATE1, gen(JDATE1) gen long NDATE2=JDATE1+ %_2 * cond("%_3" == "d", 1, 365.25) etof NDATE2, gen(FDATE2) * * Assumes both days of the dates shown are worked * di _n %7.0f "Future Date is: " = FDATE2 drop _all end