home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / bit / listserv / sasl / 4123 < prev    next >
Encoding:
Text File  |  1992-09-09  |  4.0 KB  |  83 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Newsgroups: bit.listserv.sas-l
  3. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!paladin.american.edu!auvm!uvvm!klassen
  4. References:  <920909195033_76350.1604_EHJ43-1@CompuServe.COM>
  5. Message-ID: <92253.140000KLASSEN@UVVM>
  6. Date:         Wed, 9 Sep 1992 14:00:00 PDT
  7. Reply-To:     Melvin Klassen <KLASSEN@UVVM.BITNET>
  8. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  9. Comments:     Warning -- original Sender: tag was NETNEWS@UVVM.UVIC.CA
  10. From:         Melvin Klassen <KLASSEN@UVVM.BITNET>
  11. Subject:      Re: numbers in SAS
  12. Lines: 69
  13.  
  14. Andy Norton <76350.1604@COMPUSERVE.COM> writes:
  15. >NO NO NO!  NEVER USE A LENGTH LESS THAN 8 FOR A NON-INTEGER NUMERIC VALUE!
  16. >(excuse me for getting overexcited)
  17.  
  18. You're excused, but that doesn't make you right!
  19.  
  20. >The problem is not how much precision you need.  The problem is that
  21. >you want *comparisons* to be done with exactly the same precision.
  22.  
  23. You really do *not* want that either -- you should abandon hope
  24. of getting the computer to test "equality" of two non-integer values,
  25. and instead program it to test for "approximately-equal".
  26.  
  27. >If a decimal value is stored with less than 8 bytes, it may not match.
  28.  
  29. If a decimal value is stored with even 16 or 32 or 64 bytes,
  30. the stored binary-value may *still* not match the external decimal-value!
  31.  
  32. >Remember there are also hidden comparisons which can occur in procedures,
  33. >such as determining whether observations are in the same BY-group or not.
  34.  
  35. This is the only good point in your answer!
  36. Woe on anybody who chooses to use non-integer-valued variables
  37. in BY-group processing!
  38.  
  39. I suppose that the extreme argument is that any statistical package
  40. should never hand the user a loaded gun, in order to prevent the user
  41. from shooting his/her own foot.  Balderdash!
  42.  
  43. Since round-off-errors are a fact-of-life when using non-integer numbers
  44. within computers, one should really disable the floating-point hardware,
  45. or at least remove SAS's capability of using floating-point values.   :-))))
  46. (A classic presentation given at most SHARE meetings is titled
  47. "The answers are almost right"; it's a tutorial on the dangers
  48. of finite-precision binary-arithmetic by a decimal-oriented programmer.
  49. Look for a copy of it in the Proceedings of the SHARE.)
  50.  
  51. A side-point: remember all the discussion on SAS-L a few years ago,
  52. when Version 6 was first released?  Users complained that the conversion
  53. routines (newly written in the C programming language) did not produce
  54. identical results as the "old" (written in the PL/I programming language)
  55. conversion routines?  A similar wave of complaints arose when users upgraded
  56. from the "classic" transcendental-function routines in VS FORTRAN Version 1
  57. to the "new" routines in the VS FORTRAN Version 2 library -- the "new" results
  58. are always accurate to one ULP (unit in the last place), but the users
  59. preferred the old, inaccurate routines!  My point is that external-format to
  60. internal-format conversion has always been a problem for computer-programmers,
  61. whether they write in C, PL/I, FORTRAN, or SAS.
  62.  
  63. Only a naive user of computers should expect a line of code like:
  64.      IF A EQ .1 THEN ...
  65. to actually perform what the user intended!
  66. (I exclude symbolic-manipulation packages like MAPLE and REXX,
  67. which store all numbers as indefinite-precision strings,
  68. rather than as finite-precision values.)
  69.  
  70. A user who codes the above will soon learn that this should be coded as:
  71.     IF  (A-0.1) < 1.0E-5  THEN PUT 'Close enough for jazz!'
  72. and that the statement:
  73.     DO X=0.0 to 100.0 by 0.01
  74. can produce "interesting" results. :-)
  75.  
  76. SAS provides all the tools for the user to properly code a comparison
  77. between two numeric variables, e.g., the FUZZ function (page 550 in
  78. "SAS(r) Language, Reference, Version 6, First Edition"),
  79. and a tool (the LENGTH statement) to allow the knowledgeable user
  80. to *choose* to produce SAS datasets which economize on the disk-space
  81. required for their storage.  Since "end-user computing" seems here to stay,
  82. the onus is on the user to understand the tools they choose to use.
  83.