TRUNC Function


Truncates a numeric value to a specified length

Category: Truncation

Syntax

TRUNC ( number , length )

Arguments

number

  • is numeric.

length

  • is an integer.

Details

The TRUNC function truncates a full-length number (stored as a double) to a smaller number of bytes, as specified in length and pads the truncated bytes with 0s. The truncation and subsequent expansion duplicate the effect of storing numbers in less than full length and then reading them.

Comparisons

The ROUND function returns a value rounded to the nearest round-off unit. If a round-off unit is not provided, a default value of 1 is used, and the argument is rounded to the nearest integer.

Examples

 data test;    length x 3;    x=1/5;  run;  data test2;     set test;     if x ne 1/5 then        put 'x ne 1/5';     if x eq trunc(1/5,3) then        put 'x eq trunc(1/5,3)';  run; 

The variable X is stored with a length of 3 and, therefore, each of the above comparisons is true.




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

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