LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 8 Nov 2001 09:52:04 -0800
Reply-To:   Bob <bduell@MSN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Bob <bduell@MSN.COM>
Organization:   http://groups.google.com/
Subject:   Re: Need help with invalid dates
Content-Type:   text/plain; charset=ISO-8859-1

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


Back to: Top of message | Previous page | Main SAS-L page