Numeric Variables

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.) In SAS under Windows, the Windows data type of numeric values that have a length of 8 is LONG REAL. The precision of floating-point values is accurate to approximately 15 digits. Depending on the number, the precision can be 16 digits of accuracy. For more information about the representation of the LONG REAL Windows data type, see Intel developer Web site. Significant Digits and Largest Integer by Length for SAS Variables under Windows specifies the significant digits and largest integer values that can be stored in SAS numeric variables.
Significant Digits and Largest Integer by Length for SAS Variables under Windows
Length in Bytes
Largest Integer Represented Exactly
Exponential Notation
Significant Digits Retained
3
8,192
213
3
4
2,097,152
221
6
5
536,870,912
229
8
6
137,438,953,472
237
11
7
35,184,372,088,832
245
13
8
9,007,199,254,740,992
253
15
For example, if you know that a numeric variable always has values between 0 and 100, you can use a length of 3 to store the number and thus save space in your data set. Here is an example:
data mydata;
   length num 3;
   more data lines
run;
Note: Dummy variables (those variables whose only purpose is to hold 0 or 1) can be stored in a variable whose length is 3 bytes.
CAUTION:
Use the 3-byte limit for only those variables whose values are small, preferably integers.
If the value of a variable becomes large or has many significant digits, you can lose precision when saving the results of arithmetic calculations if the length of a variable is less than 8 bytes.
The maximum number of variables is limited by the first encountered limitation:
  • the observation length
  • the total storage possible for names, labels, and metadata
  • the amount of available memory on the machine where the data set is stored.
You can define a data set with an observation length of up to 2GB on a 32-bit platform and approximately 2*46 bytes on a 64-bit platform. The observation length cannot exceed the value of the BUFSIZE option.
Assuming a single-byte character set, and that you use the maximum 352 bytes possible for name, label, and other data, for each variable, you can have a maximum of approximately 1,350,000 variables. If the names, labels, and format names are shorter, you can have more than 66,666,666. There is a maximum of 1GB to store all the variable names and other metadata (data set label, compression name, and other data). The 352 bytes is a result from 32 bytes for formats, informats and variable names, and 256 bytes for label values.
Assuming that the above limits are not exceeded the maximum possible number of variables is 412,977,617 on 32-bit hosts and 2GB on 64-bit hosts.