LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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. Sig

>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; >87 dob='0000'; >88 date=input(dob,mmddyy10.); >89 put date=; >90 run; > >NOTE: Invalid argument to function INPUT at line 88 column 8. >date=. >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. >Sig > > > >On Mon, 10 Dec 2001 10:42:59 -0500, Kaskey, Larry <LKaskey@SEISINT.COM> >wrote: > >>I am trying to check for invalid dates...here is my code... >> >>data _null_; >>file print; >>length dob $10; >>infile 'h:\data_cleanse\test_file.txt' dlm='*' missover dsd; >>input >>dob $ >>dob2 = input(dob,mmddyy10.); >>if dob = . then put dob= dob2=; >>run; >> >> >>Now, I put in as the first date a year of 0000...so the first record's date >>looks like this....'07/16/0000' I expected this to be invalid, but >instead, >>SAS appears to interpret this as 07/16/2000 and converts it to the sas date >>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. >> >>Thanks, >> >>Larry Kaskey >>ETL Developer >>Seisint,Inc >>561-999-4597


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