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 (August 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 26 Aug 2005 08:22:59 -0700
Reply-To:     Daniel Nordlund <res90sx5@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Daniel Nordlund <res90sx5@VERIZON.NET>
Subject:      Re: Cant read a Datetime using Datetime Format
Comments: To: Peter Crawford <peter1.crawford@CITIGROUP.COM>
In-Reply-To:  <200508261300.j7QD0036014886@listserv.cc.uga.edu>
Content-type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Peter > Crawford > Sent: Friday, August 26, 2005 6:00 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Cant read a Datetime using Datetime Format > > On Fri, 26 Aug 2005 01:45:49 -0700, RolandRB <rolandberry@HOTMAIL.COM> > wrote: > > >tobyrathgeb@stanford.edu wrote: > >> Hi > >> > >> I have a datetime in my raw (ASCII) file: > >> > >> 12/16/2004 9:10:31 > >> > >> but cant read it with "datetime19." format in the input statement of my > >> datastep. I saw that this format needs a 10NOV2004:18:59:59 layout of > >> raw data, however "date." and "time." separately accept parts of my raw > >> string. Can it be that this is again a limit in versatility of the sas > >> language giving me the impression that it was developed without a > >> systematic approach that usually guides a programming language. > >> > >> I appreciate your comments. > >> > >> Toby > > > > Toby > > are you sure that should be 19. or 18. ? > It's difficult to agree your comments without evidence. > > Perhaps the parsing of the data cell isn't as straightforward. > > Anyway, in sas9 try informat anydtdtm. For example: > > data to_toby; > input toby_time ; > put _infile $30. (_all_)(=); > attrib toby_time informat= anydtdtm. format= datetime. ; > cards; > 10NOV2004:18:59:59 > 10NOV2004:18:59:59.999 > 8/26/5:13:50:21.12 > 26-Aug-2005:13:38 > 26/8/2005-13:49:25 > 26/8/05-13:49:25 toby_time=05AUG26:13:49:25 > ; > > On my system it seems to work, according to this log > > 1567 data to_toby; > 1568 input toby_time; > 1569 put _infile_ $30. (_all_)(=) ; > 1570 attrib toby_time informat= anydtdtm. format= datetime. ; > 1571 cards; > > 10NOV2004:18:59:59 toby_time=10NOV04:18:59:59 > 10NOV2004:18:59:59.999 toby_time=10NOV04:19:00:00 > 8/26/5:13:50:21.12 toby_time=26AUG05:13:50:21 > 26-Aug-2005:13:38 toby_time=26AUG05:13:38:00 > 26/8/2005-13:49:25 toby_time=26AUG05:13:49:25 > 26/8/05-13:49:25 toby_time=05AUG26:13:49:25 > NOTE: The data set WORK.TO_TOBY has 6 observations and 1 variables. > > > If you don't like that last result, then remember to use y2k compliant > years. > > > Peter Crawford > > As I learn more of SAS, I also learn respect for how much > of SAS I still don't know !

The example "datetime" that Toby gave has a blank in it, which is going to cause problems on input and will need to be worked around.

Dan Nordlund Bothell, WA


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