Date: Wed, 17 Jan 2007 16:42:29 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Safe way to test if a date is valid ?
Summary: I see it as a philosophical language problem.
#iw-value=1
Mike,
I seem to remember you sitting beside me in a SUGI BOF some years ago when
Rick Langston explained that the various date informats were, by design,
triggered to end when a non-date symbol occurred.
I agree that
INPUT ('1JAN5ABCD',DATE9.)
is a little hard to swallow, but informats are for reading data where it is
somewhat easier to understand. Since you find a blank acceptable, what do
you say to
INPUT ('1JAN5 BCD',DATE9.)
I find it hard to argue with
1 data _null_ ;
2 input chk $15. @1 dt datetime. ;
3 put chk= dt= datetime20. ;
4 cards ;
chk=1JAN5,15:35:40 dt=01JAN2005:15:35:40
Perhaps one should have an agreed small set of allowable symbols that can
trigger the end of a date, but it seems somewhat like a "mother may I"
approach to the language which SAS has not traditionally adopted.
I think there are arguments for a permissive language and for a very strict
"you conform or else" language, but SAS has already made that decision.
The handling of date, time and date/time informats is consistent with that
decision, albeit not so well documented.
Ian Whitlock
=================
Date: Wed, 17 Jan 2007 08:33:10 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion"
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: Safe way to test if a date is valid ?
In-Reply-To: <011c01c739bc$69539a30$6600a8c0@IBMA9A4F058C42>
Content-Type: text/plain; charset="us-ascii"
Scott,
This seems odd to me as well.
INPUT ('123XYZ',6.) returns an error, even though within the specified
width there is a valid numeric value prior to the invalid characters. Off
the top of my head, I can't think of any good reason why INPUT
('1JAN5ABCD',DATE9.) should not return an error. The underlying situation
appears to be the same. (Trailing blanks should be OK, of course.)
Mike Rhoads Westat RhoadsM1@Westat.com
-----Original Message----- From: owner-sas-l [mailto:owner-sas-l] On Behalf
Of Scott Barry Sent: Tuesday, January 16, 2007 5:20 PM To: SAS-L ListServ
Group Subject: Re: Safe way to test if a date is valid ?
...
Also, I would consider the SAS DATE INFORMAT processing of alpha-characters
in the year to be an serious defect without question. Hopefully SAS
Institute can understand why, presuming someone reported the behavior?
For many years I've used the DATA step technique with INPUT function and
checking _ERROR_ to validate a user-specified date string as being correct.
To see Dan's post is disquieting.
Sincerely,
Scott Barry SBBWorks, Inc.