Meteorite | Level 14

round down by 1000

Hello

I want to create a new column called X_New .

The value in X_New column will be the rounded down value of column X.

The expected values are:

X=4000 ,X_New=4000

X=4200,X_New=4000

X=4500, X_New=4000

X=4600, X_New=4000

X=4900, X_New=4000

X=5000, X_New=5000

X=5100, X_New=5000

What is the way to round down by 1000 ?

``````data have;
input x;
cards;
4000
4200
4500
4600
4900
5000
5100
0
.
;
Run;``````

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

Re: round down by 1000

Use the FLOOR function

``x_new=floor(x/1000)*1000;``
--
Paige Miller
2 REPLIES 2
Diamond | Level 26

Re: round down by 1000

Use the FLOOR function

``x_new=floor(x/1000)*1000;``
--
Paige Miller
SAS Super FREQ

Re: round down by 1000

As Paige says, the FLOOR function will round all numbers toward negative infinity.

For negative values, some people prefer to round toward zero. If you want to round toward zero, use the INT function:

``x_new=int(x/1000)*1000;``