Previous Page | Next Page

Functions and CALL Routines

TRUNC Function



Truncates a numeric value to a specified number of bytes.
Category: Truncation

Syntax
Arguments
Details
Examples

Syntax

TRUNC(number,length)


Arguments

number

specifies a numeric constant, variable, or expression.

length

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


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.

Previous Page | Next Page | Top of Page