Date: Fri, 24 Oct 2008 06:34:36 -0500
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: 1/1/2008 informat
In-Reply-To: <941871A13165C2418EC144ACB212BDB0BEB1F9@dshsmxoly1504g.dshs.wa.lcl>
Content-Type: text/plain; charset=ISO-8859-1
Did you get the expected result for E? It doesn't look like it to me.
33 data test ;
34 input d mmddyy10. e $4.;
35 format d date9.;
36 list;
37 put d= e;
38 cards;
d=01JAN2008
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
39 1/1/08 123
d=02FEB2008 23
40 2/2/2008 123
On 10/23/08, Nordlund, Dan (DSHS/RDA) <NordlDJ@dshs.wa.gov> wrote:
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On
> > Behalf Of Howard Schreier <hs AT dc-sug DOT org>
> > Sent: Thursday, October 23, 2008 7:12 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: 1/1/2008 informat
> >
> > On Thu, 23 Oct 2008 14:37:52 -0700, Nordlund, Dan (DSHS/RDA)
> > <NordlDJ@DSHS.WA.GOV> wrote:
> >
> > >> -----Original Message-----
> > >> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On
> > >> Behalf Of Joe Matise
> > >> Sent: Thursday, October 23, 2008 2:28 PM
> > >> To: SAS-L@LISTSERV.UGA.EDU
> > >> Subject: Re: 1/1/2008 informat
> > >>
> > >> I think MMDDYY8. expects
> > >> 10/20/08
> > >> not
> > >> 1/1/2008
> > >>
> > >> and though I think it is probably going to correctly read it
> > >> anyway (SAS is
> > >> pretty good about that), it's better to use MMDDYY10. as that more
> > >> accurately reflects the data ... and presumably he has data
> > >> like 1/15/2008
> > >> which is not 8 long, anyway.
> > >>
> > >> -Joe
> > >>
> > >> On Thu, Oct 23, 2008 at 4:13 PM, Akshaya
> > >> <akshaya.nathilvar@gmail.com>wrote:
> > >>
> > >> > Can also use the mmddyy8. informat to read in the data.
> > >> >
> > >> > Akshaya-
> > >> >
> > >>
> > >Yes, 1/1/2008 will be read correctly by mmddyy8., but 01/01/2008 or
> > 10/10/2008 will not be read correctly. So it is indeed more
> > safe to use
> > mmddyy10.
> >
> > Right, but there's more to it. The original poster did not
> > indicate context.
> > What if scanning 10 characters for the date eats part of the
> > next field, or
> > runs past the end of the record? One may need a colon (:)
> > modifier, or the
> > TRUNCOVER option, or a pre-established informat.
> >
> Howard,
>
> I have been bitten :-) by that before, and tested the following code before I posted.
>
> data test ;
> input d mmddyy10. e $4.;
> format d date9.;
> put d=;
> cards;
> 1/1/08 123
> 2/2/2008 123
> ;
> run;
>
> As long as there is at least one space after the date, it apparently ignores trailing junk. But I agree, there are times when discretion is the better part of valor (and, but for the test, I would have thought this was one of them). And if you know your fields may vary in length, programming defensively with the colon (:) format modifier may be the safest approach.
>
> Dan
>
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204
>
|