Numeric Variables


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 always accurate to 15 digits. Depending upon the number, the precision may be 16 digits of accuracy. For more information about the representation of the LONG REAL Windows data type, see Intel s developer Web site. Table 23.1 on page 579 specifies the significant digits and largest integer values that can be stored in SAS numeric variables.

Table 23.1: 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

2 13

3

4

2,097,152

2 21

6

5

536,870,912

2 29

8

6

137,438,953,472

2 37

11

7

35,184,372,088,832

2 45

13

8

9,007,199,254,740,992

2 53

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 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 may 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 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.




SAS 9.1 Companion for Windows
SAS 9.1 Companion for Windows (2 Volumes)
ISBN: 1590472004
EAN: 2147483647
Year: 2004
Pages: 187

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net