hi please see if this is what you want;program will also take care of consecutive missing months. data test; input date_have :datetime21.; format date_have datetime21.; diff=dif(datepart(date_have)); if dif(datepart(date_have))>1 then do i=1 to diff-1; date_have=date_have; output; date_have=date_have-24*60*60; missing=1; end; output; cards; 01DEC2008:09:22:25 02DEC2008:10:23:45 04DEC2008:10:23:45 08DEC2008:10:23:45 10JAN2009:10:23:45 20FEB2009:10:23:45 ; proc sort data=test; by date_have; run; data test(keep=date_want); set test; date_have_char=put(date_have,datetime21.); date_want=catx('/',scan(date_have_char,1,':'),catx(':',scan(date_have_char,2,':'),scan(date_have_char,3,':'))) ; if missing=1 then date_want=catx('/',put(datepart(date_have),monyy7.),'UNKNOWN'); run; OUTPUT: -------------- date_want=01DEC2008/09:22 date_want=02DEC2008/10:23 date_want=DEC2008/UNKNOWN date_want=04DEC2008/10:23 date_want=DEC2008/UNKNOWN date_want=DEC2008/UNKNOWN date_want=DEC2008/UNKNOWN date_want=08DEC2008/10:23 ..... ... ... date_want=JAN2009/UNKNOWN date_want=10JAN2009/10:23 ..... ... ... date_want=FEB2009/UNKNOWN date_want=20FEB2009/10:23
... View more