Chapter Contents

Previous

Next
SAS Companion for the Microsoft Windows Environment

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 the SAS System under Windows, the Windows data type of numeric values that have a length of 8 is LONG REAL. The precision of this type of floating-point values is 16 decimal digits. For more information about the representation of the LONG REAL Windows data type, see Intel Corporation's i486 Microprocessor Programmer's Reference Manual. 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
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

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 whose only purpose is to hold 0 or 1) can be stored in a variable whose length is 3 bytes.  [cautionend]

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 may lose precision when saving the results of arithmetic calculations if the length of a variable is less than 8 bytes.  [cautionend]

The maximum number of variables in a single SAS data set under Windows is 32,767. In addition, an observation under Windows cannot be longer than 5M. Therefore, if you want your data set to contain 32,767 character variables, the longest each variable can be is 160 bytes.

However, a DATA step can reference more than 32,767 variables, if you write only 32,767 or fewer variables to the data set. For example, you could drop some variables with a DROP= data set option. The maximum number of variables a DATA step can reference under Windows is 2,147,483,647.


Chapter Contents

Previous

Next

Top of Page

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