Functions and CALL Routines |
Truncates a numeric value to a specified number of bytes.
-
number
-
specifies a numeric constant, variable,
or expression.
-
length
-
specifies 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.
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.
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.