|
Jim,
SAS can't automatically "correct" these dates. But you can turn them
into character variables and investigate the issue. Once you find a
correctable pattern, you can apply code to make real dates. Perhaps
you can find that these bad dates are always "one off" from the "real"
date. Here's what I'd try:
data check;
length cdate $9 /* A character field for the original date */
badflag $1 /* Y indicates an unrecoverable bad date */
/* N indicates it's a good date */
/* X indicates it was bad, but corrected */
rdate 4; /* The new SAS date, if possible */
input @1 MVSdate pd5.;
cdate = put(MVSdate,z9.);
if substr(cdate,1,1) ne '0' then badflag = 'Y';
else do;
rdate = input(substr(cdate,2,8),yymmdd8.);
if rdate ne . then badflag = 'Y'; /* It's a good date */
else do;
/* Try and subtract one from the day portion */
rdate = input(substr(cdate,2,6) ||
put(input(substr(cdate,8,2),2.) - 1,z2.),
yymmdd8.);
if rdate = . then badflag = 'Y';
else badflag = 'X';
end;
end;
run;
Now you can print any dates that are still "bad" (badflag = 'Y'),
look for more patterns, and continue to revise the program.
Good luck,
Bob
|