|Date: ||Mon, 10 Dec 2001 14:26:35 -0500|
|Reply-To: ||Sigurd Hermansen <hermans1@WESTAT.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Sigurd Hermansen <hermans1@WESTAT.COM>|
|Subject: ||Re: sas dates|
Venky Chakravarthy has advised me discretely that I did not read the
question carefully enough. Thanks, Venky. After rereading the posting, I
now have a better understanding of the problem. It appears that you will
have to work around what appears to be a serious defect in the mmddyy10.
informat. I have never observed that problem, and may not have been willing
to face the fact that it might work that way.
Others have suggested that you break down you date into mm, dd, yyyy
components and use the MDY() function to convert the components into a SAS
date. We do that routinely but not to work around the problem that you have
observed. Instead, we may choose to impute missing dd or mm values in some
contexts, and to preserve legal mm and dd values for other purposes.
>I would not assume that SAS programmers have a general and graceful
>solution for the problem of invalid dates INPUT or imported from anything
>other than SAS dates. Your example does not by any means exhaust the list
>of possible sources of confusion.
>Having said this, I can't replicate what you found. For what appears to me
>to be essentially the same program, SAS produces an error message and sets
>the value of the date variable to missing:
>85 data _null_;
>86 length dob $ 10;
>89 put date=;
>NOTE: Invalid argument to function INPUT at line 88 column 8.
>dob=0000 date=. _ERROR_=1 _N_=1
>NOTE: Mathematical operations could not be performed at the following
>places. The results of the operations have been set to
> missing values.
> Each place is given by: (Number of times) at (Line):(Column).
> 1 at 88:8
>NOTE: DATA statement used:
> real time 0.05 seconds
>The same program converts the string value '11300000' to the expected
>numeric value of 14944, but produces an error message and missing numeric
>value when fed '11310000'.
>You may have special defaults or other complications. While the SAS
>compiler does not handle all of the complications that one might see in
>external data sources, it does not as a rule make such an obvious mistake.
>On Mon, 10 Dec 2001 10:42:59 -0500, Kaskey, Larry <LKaskey@SEISINT.COM>
>>I am trying to check for invalid dates...here is my code...
>>length dob $10;
>>infile 'h:\data_cleanse\test_file.txt' dlm='*' missover dsd;
>>dob2 = input(dob,mmddyy10.);
>>if dob = . then put dob= dob2=;
>>Now, I put in as the first date a year of 0000...so the first record's
>>looks like this....'07/16/0000' I expected this to be invalid, but
>>SAS appears to interpret this as 07/16/2000 and converts it to the sas
>>14807...I have a feeling this is something that most people here are aware
>>of, but if someone can provide an explanation or a way for me to test for
>>invalid dates of this nature, I would greatly appreciate it.