home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!bu.edu!olivea!sgigate!sgiblab!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.american.edu!auvm!UNC.BITNET!LZM
- From: LZM@UNC.BITNET (Li, Zhiming (919-933-9778))
- Newsgroups: bit.listserv.sas-l
- Subject: Reason found: PC-SAS 6.04: one day gap between input and display
- Message-ID: <SAS-L%92101515074201@VTVM2.CC.VT.EDU>
- Date: 15 Oct 92 19:08:00 GMT
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- Reply-To: "Li, Zhiming (919-933-9778)" <LZM@UNC.BITNET>
- Lines: 80
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
-
- Dear netters:
-
- Yesterday I post a message asking for your help for the problem
- I encounted in using SAS informat and format MMDDYY6. and MMDDYY8.
- (see the attached message below for those who did not read my last
- message).
-
- > Recently I used PC-SAS/FSP version 6.04 to enter data. I created a
- >sas dataset containing a variable named DATE using informat MMDDYY6.,
- >and the variable was also assigned a format MMDDYY8., using the program
- >below:
- > DATA SASDATA.ONE;
- > INPUT DATE;
- > INFORMAT DATE MMDDYY6.;
- > FORMAT DATE MMDDYY8.;
- > RUN;
- >Then I ran the following program to read the dataset into the FSEDIT
- >program:
- > PROC FSEDIT DATA=SASDATA.ONE SCREEN=SASDATA.SCREEN; RUN;
- >Then the FSEDIT program was ready to enter data. When I entered 100192
- >it should show up as 10/01/92 due to the informat and format I chose.
- >But to my surprise, one day was off: the 100192 I entered showed up
- >on the screen as 09/30/92! I tried some other days in October 1992,
- >it would still show one day difference.
-
- Today I found THE REASON FOR THE PROBLEM:
- I HAD ASSIGNED THE VARIABLE WITH A LENGTH OF 3!
- As you may know, a length of 3 can retain only the first 4 significant
- digits of a numeric variable, but the current dates counted from 1960
- are 5-digits numbers, and the fifth digits are rounded when using a
- length of 3 to these 5-digit numbers: odd numbers are rounded to the
- smaller even numbers.
-
- I tested this in the program below:
-
- data one;
- input data1 date2;
- informat date1 date2 mmddyy6.; * same informat;
- format date1 date2 mmddyy8.; * same format;
- length data1 3 data2 5; * different lengths;
- run;
- proc fsedit; run; * enter same 093092 100192 100292 100392 100492
- to the two variables;
- proc print; title 'dates printed with MMDDYY8. format'; run;
- data two; set one; format _all_; run;
- proc print; title 'dates printed without MMDDYY8. format'; run;
-
- And below is the SAS output:
-
- dates printed with MMDDYY8. format
-
- OBS DATA1 DATA2
-
- 1 09/29/92 09/30/92
- 2 10/01/92 10/01/92
- 3 10/01/92 10/02/92
- 4 10/03/92 10/03/92
- 5 10/03/92 10/04/92
-
- dates printed without MMDDYY8. format
-
- OBS DATA1 DATA2
-
- 1 11960 11961
- 2 11962 11962
- 3 11962 11963
- 4 11964 11964
- 5 11964 11965
-
- The lessen: DO NOT USE A LENGTH OF 3 FOR DATE VARIABLES.
-
- Thank you, especially those who kindly tried to replicate the
- the problem and gave me suggestion.
-
- =======================================================================
- Zhiming Li E-mail: LZM@UNC.BITNET
- Dept. of Medicine LZM@UNC.OIT.UNC.EDU
- Univ. of North Carolina Tel: 919-966-6370
- Chapel Hill, NC 27599 FAX: 919-966-5099
- =======================================================================
-