There are many decimal fractions whose binary equivalents are infinitely repeating
binary numbers, so be careful when interpreting results from general rational numbers in
decimal. There are some rational numbers that do not present problems in either number
system. For example, 1/2 can be finitely represented in both the decimal and binary
systems.
To understand better why a simple calculation such as this one can go wrong, or how a
number can be out of range, it is important to understand in more detail how SAS stores
binary numbers.
How SAS Stores Numeric Values
Maximum Integer Size
SAS stores all numeric values in 8 bytes of storage unless you specify differently. This
does not mean that a value is limited to 8 digits, but rather that 8 bytes are allocated for
storing the value. In the previous section, you learned how storing non-integer values
(fractions) can lead to problems with precision. But you can also encounter problems of
magnitude, or range, when working with integers (whole numbers).
On any computer, there are limits to how large the absolute value of an integer can be. In
SAS, this maximum integer value depends on two factors:
• the number of bytes that you explicitly specify for storing the variable (using the
LENGTH statement)
• the operating environment on which SAS is running
If you have not explicitly specified the number of storage bytes, then SAS uses the
default length of 8 bytes, and the maximum integer then depends solely on what
operating system you are using.
The following table lists the largest integer that can be reliably stored by a SAS variable
in the mainframe, UNIX, and Windows operating environments.
Table 4.8 Largest Integer That Can Be Safely Stored in a Given Length
When Variable
Length
Equals ...
Largest Integer
z/OS
Largest Integer
Windows/UNIX
2 256 not applicable
3 65,536 8,192
4 16,777,216 2,097,152
5 4,294,967,296 536,870,912
6 1,099,511,627,776 137,438,953,472
7 281,474,946,710,656 35,184,372,088,832
8 (default) 72,057,594,037,927,936 9,007,199,254,740,992
When viewing this table, consider the following points:
62 Chapter 4 • SAS Variables