Pages

Friday 4 September 2009

NOTE: The CONSTANT Function

I've been using SAS since 1983 and I'm always somewhat frustrated when I discover a function I've never heard of (even though it may have been introduced to SAS recently). Have you heard of the CONSTANT function? Well, I hadn't until yesterday.

In the context of understanding the precision of numeric data in SAS, we discovered the CONSTANT function and its "MACEPS" argument. MACEPS returns the "machine precision constant"; the SAS 9.2 Language Reference: Dictionary tells us that the following other arguments are available:
  • The natural base
  • Euler constant
  • Pi
  • Exact integer
  • The largest double-precision number
  • The logarithm of BIG
  • The square root of BIG
  • The smallest double-precision number
  • The logarithm of SMALL
  • The square root of SMALL
  • Machine precision
  • The logarithm of MACEPS
  • The square root of MACEPS
So, if you need the value of Pi (for instance), you no longer need to hard-code it.
A bit of research shows it has been available since at least V8, so my frustration of being unaware of it is compounded!