Date: Fri, 11 May 2007 18:30:11 -0400
Reply-To: "data _null_;" <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_;" <datanull@GMAIL.COM>
Subject: Re: Inputting Date/Time Values Stored As Text
In-Reply-To: <7367b4e20705111528u6614a614q4ea8ef1ea552a8a4@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Well DATA _NULL_ because IS8601DT is probably some kind of alias for YMDDTTM.
On 5/11/07, data _null_; <datanull@gmail.com> wrote:
> I wonder why you didn't find is8601dt
>
> On 5/11/07, Peter Crawford <peter.crawford@blueyonder.co.uk> wrote:
> > On Fri, 11 May 2007 10:25:34 -0700, Scott Barry <sbarry@SBBWORKS.COM>
> > wrote:
> >
> > >On May 11, 12:21 pm, "Deborah Testa" <dte...@sevenofninesystems.com>
> > >wrote:
> > >> Hello,
> > >>
> > >> I am working with a data file that stored date/time values as text like
> > >> this:
> > >>
> > >> 2005-08-01 17:52:33
> > >>
> > >> Is there a quick way to get this into a datetime variable without
> > >> parsing the two pieces?
> > >>
> > >> Thanks,
> > >>
> > >> Deborah
> > >
> > >In a DATA step, use the INPUT statement to read up the two fields
> > >using the appropriate "date" and "time" INFORMAT, and then combine
> > >them into a "datetime" variable using the DHMS function, substituting
> > >the "time" variable as the Seconds argument of DHMS, and use "0" for
> > >the Hour and Minute arguments.
> > >
> > >Scott Barry
> > >SBBWorks, Inc.
> >
> >
> > Hi Scott
> >
> > I've been using the SAS9 sashelp.vformat resource to search for correct
> > informats.
> >
> > The code
> > data test ;
> > set sashelp.vformat ;
> > where fmttype='I' ; *just informats;
> > where also fmtname ne:'$' ; * and not character informats;
> >
> > string = '2005-08-01 17:52:33' ;
> >
> > nd = inputn( string, fmtname, 27 );
> > if not _error_ ;
> >
> > put fmtname= nd=best32. +1 nd datetime. +1 string=;
> > option errors = 1;
> > run;
> >
> > The results show also that some date informats will return a non -missing
> > value, but only these two achieve the correct timestamp.
> >
> > extracted from the log
> >
> > fmtname=ANYDTDTM nd=1438537953 01AUG05:17:52:33 string=2005-08-01 17:52:33
> > fmtname=YMDDTTM nd=1438537953 01AUG05:17:52:33 string=2005-08-01 17:52:33
> >
> >
> > Peter C
> >
>
|