Numeric Precision - Storing an Integer
The default length of a numeric variable is 8 bytes. Numeric variables in SAS are stored in floating point format (essentially 1 byte for an exponent and 7 bytes for the mantissa). The exact representation varies from machine to machine. On all machines I know of, the storage representation is called "double-precision floating point." On most unix machines this type of storage (8 bytes) yields 16 decimal digits of precision. If you store a number in less bytes, you loose some precision.
The table below shows the largest integer such that all integers less than or equal to it can be exactly represented by a floating point number with the given number of bytes.
Length in bytes |
Largest Integer Represented Exactly |
Exponential |
3 |
8,192 |
2**13 |
4 |
2,097,152 |
2**21 |
5 |
~536 million |
2**29 |
6 |
~137 billion |
2**37 |
7 |
~35 trillion |
2**45 |
8 |
~9,007 trillion |
2**53 |
A floating-point number must be stored in at least 3 bytes when using SAS on a PC.