Chapter Contents

Previous

Next
TRUNC

TRUNC



Truncates a numeric value to a specified length

Category: Truncation


Syntax
Arguments
Details
Comparisons
Examples

Syntax

TRUNC(number,length)

Arguments

number
is numeric.

length
is numeric and 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.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.