It's always a tradeoff between validation strength and complexity, This should filter out many anomalies:
data want;
if not id then id + prxparse(
"/([12][90]\d\d-[01]\d-[0123]\d|[12][90]\d\d-[01]\d|[12][90]\d\d)[ T]([012]\d:[012345]\d|[012]\d:)?/io");
set have;
length adtmc $16;
if prxmatch(id, ecdtc) then do;
d = prxposn(id, 1, ecdtc);
t = prxposn(id, 2, ecdtc);
adtmc = catx(" ",
catx("-", scan(d,1), coalescec(scan(d,2), "XX"), coalescec(scan(d,3), "XX")),
catx(":", coalescec(scan(t,1,":"), "XX"), coalescec(scan(t,2,":"), "XX")) );
end;
else adtmc = ecdtc;
drop id d t;
run;
... View more