home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / bit / listserv / sasl / 4562 < prev    next >
Encoding:
Internet Message Format  |  1992-10-15  |  3.4 KB

  1. 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
  2. From: LZM@UNC.BITNET (Li, Zhiming (919-933-9778))
  3. Newsgroups: bit.listserv.sas-l
  4. Subject: Reason found: PC-SAS 6.04: one day gap between input and display
  5. Message-ID: <SAS-L%92101515074201@VTVM2.CC.VT.EDU>
  6. Date: 15 Oct 92 19:08:00 GMT
  7. Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. Reply-To: "Li, Zhiming (919-933-9778)" <LZM@UNC.BITNET>
  9. Lines: 80
  10. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  11.  
  12. Dear netters:
  13.  
  14.     Yesterday I post a message asking for your help for the problem
  15. I encounted in using SAS informat and format MMDDYY6. and MMDDYY8.
  16. (see the attached message below for those who did not read my last
  17. message).
  18.  
  19. >     Recently I used PC-SAS/FSP version 6.04 to enter data. I created a
  20. >sas dataset containing a variable named DATE using informat MMDDYY6.,
  21. >and the variable was also assigned a format MMDDYY8., using the program
  22. >below:
  23. >  DATA SASDATA.ONE;
  24. >  INPUT DATE;
  25. >  INFORMAT DATE MMDDYY6.;
  26. >  FORMAT DATE MMDDYY8.;
  27. >  RUN;
  28. >Then I ran the following program to read the dataset into the FSEDIT
  29. >program:
  30. >  PROC FSEDIT DATA=SASDATA.ONE SCREEN=SASDATA.SCREEN; RUN;
  31. >Then the FSEDIT program was ready to enter data. When I entered 100192
  32. >it should show up as 10/01/92 due to the informat and format I chose.
  33. >But to my surprise, one day was off: the 100192 I entered showed up
  34. >on the screen as 09/30/92! I tried some other days in October 1992,
  35. >it would still show one day difference.
  36.  
  37.     Today I found THE REASON FOR THE PROBLEM:
  38. I HAD ASSIGNED THE VARIABLE WITH A LENGTH OF 3!
  39. As you may know, a length of 3 can retain only the first 4 significant
  40. digits of a numeric variable, but the current dates counted from 1960
  41. are 5-digits numbers, and the fifth digits are rounded when using a
  42. length of 3 to these 5-digit numbers: odd numbers are rounded to the
  43. smaller even numbers.
  44.  
  45.     I tested this in the program below:
  46.  
  47.  data one;
  48.   input data1 date2;
  49.   informat date1   date2 mmddyy6.;  * same informat;
  50.   format   date1   date2 mmddyy8.;  * same format;
  51.   length   data1 3 data2 5;         * different lengths;
  52.   run;
  53.  proc fsedit; run;      * enter same 093092 100192 100292 100392 100492
  54.                            to the two variables;
  55.  proc print;  title 'dates printed with MMDDYY8. format'; run;
  56.  data two; set one; format _all_; run;
  57.  proc print;  title 'dates printed without MMDDYY8. format'; run;
  58.  
  59. And below is the SAS output:
  60.  
  61.  dates printed with MMDDYY8. format
  62.  
  63.  OBS       DATA1     DATA2
  64.  
  65.   1     09/29/92  09/30/92
  66.   2     10/01/92  10/01/92
  67.   3     10/01/92  10/02/92
  68.   4     10/03/92  10/03/92
  69.   5     10/03/92  10/04/92
  70.  
  71.  dates printed without MMDDYY8. format
  72.  
  73.  OBS    DATA1     DATA2
  74.  
  75.   1     11960     11961
  76.   2     11962     11962
  77.   3     11962     11963
  78.   4     11964     11964
  79.   5     11964     11965
  80.  
  81.     The lessen: DO NOT USE A LENGTH OF 3 FOR DATE VARIABLES.
  82.  
  83.     Thank you, especially those who kindly tried to replicate the
  84. the problem and gave me suggestion.
  85.  
  86. =======================================================================
  87. Zhiming Li                           E-mail: LZM@UNC.BITNET
  88. Dept. of Medicine                            LZM@UNC.OIT.UNC.EDU
  89. Univ. of North Carolina              Tel:    919-966-6370
  90. Chapel Hill, NC 27599                FAX:    919-966-5099
  91. =======================================================================
  92.