Dates and if/then else
Dates and if/then else
(OP)
Good afternoon,
In a nutshell: we have a date range of 01/01/2011 and 01/31/2011. If the date in the Due date column is in the rnage the new date should be 12/31/2010.
We've tried these three if/then steps so far with no luck:
IF ' 01/01/2011'>=FAKE_DT<= ' 01/31/2011 ' then put ' 12/31/2010'; else
if CE_DUE_DT >= 18628 and CE_DUE_DT <= 18658 then CE_DUE_DT = 18627; else
If 18628 >=FAKE_DT<=18658 then CE_DUE_DT = 18627; else
Basically...the new CE Due Dt needs to be the last day of the previous month.
Can anyone help?
In a nutshell: we have a date range of 01/01/2011 and 01/31/2011. If the date in the Due date column is in the rnage the new date should be 12/31/2010.
We've tried these three if/then steps so far with no luck:
IF ' 01/01/2011'>=FAKE_DT<= ' 01/31/2011 ' then put ' 12/31/2010'; else
if CE_DUE_DT >= 18628 and CE_DUE_DT <= 18658 then CE_DUE_DT = 18627; else
If 18628 >=FAKE_DT<=18658 then CE_DUE_DT = 18627; else
Basically...the new CE Due Dt needs to be the last day of the previous month.
Can anyone help?
RE: Dates and if/then else
Example
CODE
date = '01SEP10'd ;
lastDay = intnx('month',date,0,'B')-1 ;
format date lastday date9. ;
put _all_ ;
run ;
Here's a few examples of finding whether a date is in a range (I would suggest putting the dates into variables, or using the 'd to make the code more human readable).
CODE
fromDt = '01SEP10'd ;
toDt = '30SEP10'd ;
dummy = '15SEP10'd ;
if fromDt <= dummy <= toDt then put 'Y';else put 'N' ;
if dummy >= fromDt and dummy <= toDt then put 'Y';else put 'N' ;
run;