Truncates a numeric value to a specified length
Category: Truncation
TRUNC ( number , length )
number
is numeric.
length
is an integer.
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.
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.
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.