| Date: | Tue, 7 Dec 1999 16:33:02 +0100 |
| Reply-To: | peter.crawford@DB.COM |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Peter Crawford <peter.crawford@DB.COM> |
| Subject: | Re: reading an ASCI file with date vars (Strange behaviors for
informat modifier |
|
| Content-type: | text/plain; charset=us-ascii |
|---|
" floating formats " using that :
ignore the input lengths indicated in an informat, (assuming the widest ?)
data xx;
input d1 : mmddyy8. d2: mmddyy8.;
*input d1 : mmddyy10. d2: mmddyy10.;
cards;
12/25/1996 03/04/96
12/25/96 05/07/1993
;
proc print;
format d1 d2 date9.;
run;
33 data xx;
34 input d1 : mmddyy8. d2: mmddyy8.;
35 *input d1 : mmddyy10. d2: mmddyy10.;
36 cards;
NOTE: The data set WORK.XX has 2 observations and 2 variables.
NOTE: The DATA statement used 0.15 seconds.
39 ;
40 proc print; title='floating formats';
41 format d1 d2 date9.;
42 run;
NOTE: The PROCEDURE PRINT used 0.04 seconds.
floating formats 13:44 Tuesday, December 7, 1999 2
OBS D1 D2
1 25DEC1996 04MAR1996
2 25DEC1996 07MAY1993
Datum: 07.12.99 16:25
An: SAS-L@listserv.uga.edu
Antwort an: Y.Huang@organoninc.com
Betreff: Re: reading an ASCI file with date vars (Strange behaviors for in
format modifier)
Nachrichtentext:
Hello all,
Would anybody mind to try the following code?
It was very interesting to find that if you use ":" as
informat modifier, no matter what informat your use,
mmddyy8. or mmddyy10., they all get the same result.
Even though in the second case (mmddyy10.), the original date
is not all 10 char long! Isn't it weird?
data xx;
input d1 : mmddyy8. d2: mmddyy8.;
*input d1 : mmddyy10. d2: mmddyy10.;
cards;
12/25/1996 03/04/96
12/25/96 05/07/1993
;
proc print;
format d1 d2 date9.;
run;
Any good explanation?
Ya Huang
Organon Inc.
> -----Original Message-----
> From: dkb@CIX.COMPULINK.CO.UK [mailto:dkb@CIX.COMPULINK.CO.UK]
> Sent: Tuesday, December 07, 1999 9:42 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: reading an ASCI file with date vars
>
>
> Panos Papanikolaou asks:>
> > Dear All,
> >
> > i am trying to read an ASCI file where two variables are date
> > variables. Specifically, these are admission and discharge dates.
> >
> > For some reason, SAS unfortunately cannot go thru and so I would
> > be grateful if I would receiveany comments on how to proceed.
> >
> > For convenience, I have put below a few lines from the data-set
> > together with SAS log and the Print-out.
> >
> > I would appreciate very much your assistance. I look forward to
> > hearing from you.
> >
> > Yours sincerely
> > Panos
> >
> > /* **************** THE DATA
> ********************************** */
> >
> > A000381 BOARDMAN 12/25/1996 01/02/1997 2
> > A000784 DAVIES 02/19/1997 02/25/1997 2
> > A000980 GRIFFITHS 07/23/1997 07/29/1997 4
> > A004094 GIBBENS 05/08/1997 05/19/1997 2
> >
> > /* ********** THE SAS LOG ****************** */
> >
> > 1172
> > 1173 title1 "Data for Marital Status and period 1996-
> > 97 " ;
> > 1174
> > 1175 data temp_ms
> > ;
> > 1176 infile 'c:\panos\sores\sas_data\panos_ms.dat'
> > ;
> > 1177 input crn $char7. surname $char9. ce_admit
> > mmddyy8. ce_disch mmddyy8. ms ;
> > 1178
> >
> > NOTE: The infile 'c:\panos\sores\sas_data\panos_ms.dat'
> > is:
> > FILENAME=c:\panos\sores\sas_data\panos_ms.dat,
> > RECFM=V,LRECL=256
> >
> > NOTE: Invalid data for CE_DISCH in line 1 25-32.
> > NOTE: Invalid data for MS in line 1 33-38.
> > RULE: ----+----1----+----2----+----3----+----4----+-
> > ---5----+----6----+----7----+----8----+
> > 1 A000381 BOARDMAN 12/25/1996 01/02/1997 2 40
> > CRN=A000381 SURNAME=BOARDMAN CE_ADMIT=-21191 CE_DISCH=.
> <snip>
>
> Panos,
>
> First of all, thanks for making an effort to post the bits we need, it
> makes the job a lot easier! There are a couple of points:
>
> * Your dates are ten characters wide, not eight - count 'em
> and remember
> to include the /. Try mmddyy10.
>
> * Your surnames are being read as always nine characters in width, so
> they come out with silly values like SURNAME=" DAVIES 0" and you crash
> into the middle of the date field as a result. Try $9. instead of
> $char9. to fix this.
>
> Have a shot with those two changes and see how much further you get.
>
> Dave
> .
>
|