Numeric Variable Length and Precision in UNIX Environments

The default length of numeric variables in SAS data sets is 8 bytes. (You can control the length of SAS numeric variables with the LENGTH or ATTRIB statements in the DATA step.)
The issue of numeric precision affects the return values of almost all SAS math functions and many numeric values returned from SAS procedures. Numeric values in SAS for UNIX are represented as IEEE double-precision floating-point numbers. The decimal precision of a full 8-byte number is effectively 15 decimal digits.
The following table specifies the significant digits and largest integer that can be stored exactly in SAS numeric variables.
Significant Digits and Largest Integer by Length for SAS Variables under UNIX
Length in Bytes
Significant Digits
Retained
Largest Integer
Represented Exactly
3
3
8,192
4
6
2,097,152
5
8
536,870,912
6
11
137,438,953,472
7
13
35,184,372,088,832
8
15
9,007,199,254,740,992
When you are specifying variable lengths, keep in mind that the length of a variable affects both the amount of disk space used and the number of I/O operations required to read and write the data set.
If you know that the value of a numeric variable will be an integer between -8192 and 8192 inclusive, you can use a length of 3 to store the number and thus save space in your data set. For example:
data mydata;
   length num 3;
   ...more SAS statements...
run;
Numeric dummy variables (variables whose only purpose is to hold 0 or 1) can be stored in a variable whose length is 3 bytes.
CAUTION:
Use the LENGTH statement to reduce length only for variables whose values are always integers.
Fractional numbers lose precision if they are truncated. In addition, you must ensure that the values of your variable will always be represented exactly in the number of bytes that you specify. You can do this programmatically in a DATA step with the TRUNC function. No warnings or errors are issued when the length that you specify in the LENGTH statement results in the truncation of data.
For more information about specifying variable lengths and optimizing system performance, see SAS Language Reference: Concepts.