Chapter Contents


SAS Companion for UNIX Environments

Numeric Variable Length and Precision

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 statement in the DATA step.)

The issue of numeric precision affects the return values of almost all SAS System math functions and many numeric values returned from SAS System procedures. Numeric values in the SAS System for UNIX are represented as IEEE double-precision floating-point numbers. The decimal precision of a full 8-byte number is approximately 16 decimal digits.

Significant Digits and Largest Integer by Length for SAS Variables under UNIX 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 Largest IntergerRepresented Exactly ExponentialNotation
3 8,192 213
4 2,097,152 221
5 536,870,912 229
6 137,438,953,472 237
7 35,184,372,088,832 245
8 9,007,199,254,740,992 253

When you are specifying variable lengths, keep in mind that variable length affects both the amount of memory used and the time required for I/O and arithmetic operations. See SAS Language Reference: Dictionary for more information on specifying variable lengths.

If you know that a numeric variable will be between 0 and 100, 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...
Numeric dummy variables (those whose only purpose is to hold 0 or 1) can be stored in a variable whose length is 3 bytes.
Use 3 bytes only for those variables with small values, preferably integers. If the value of a variable becomes large or has many significant digits, you may lose precision in arithmetic calculations when the length of a variable is less than 8 bytes.  [cautionend]

For more information on specifying variable lengths and optimizing system performance, refer to SAS Language Reference: Concepts.

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.