ROUND: Rounding a Number to a Given Number of Decimal Places

How to:

Given a numeric expression and an integer count, ROUND returns the numeric expression rounded to that number of decimal places. If the number of decimal places is negative, it rounds to the left of the decimal point.

Syntax: How to Round a Number to a Given Number of Decimal Places

ROUND(num_exp, count)

where:

num_exp

Numeric

Is the numeric expression to be rounded.

count

Numeric

Is the number of decimal places to which the numeric expression is to be rounded. If the number of decimal places is negative, ROUND rounds to the left of the decimal point.

Example: Rounding a Number to a Given Number of Decimal Places

The following request rounds the LISTPR field to zero decimal places and the NEWLISTPR field 1 decimal place and to -2 decimal places.

TABLE FILE MOVIES
PRINT LISTPR
AND  COMPUTE
NEWLISTPR/D12.3 = LISTPR * 99;
ROUND_ZERO/D12.3 = ROUND(LISTPR, 0);
ROUND_PLUS1/D12.3 = ROUND(NEWLISTPR, 1);
ROUND_MINUS1/D12.3 = ROUND(NEWLISTPR, -2);
BY MOVIECODE
WHERE RECORDLIMIT EQ 3
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

The output is shown in the following image.