## Formatting numbers.

Solved
Occasional Contributor
Posts: 7

# Formatting numbers.

Perhaps it quite simple, but I need to easily convert my data in multiples of 100 only like 619 should be 600, 754 should be 700,1238976 should be 1238900. Any easy fix? Thanks a lot.

Accepted Solutions
Solution
‎02-28-2018 02:00 PM
Super User
Posts: 24,027

## Re: Formatting numbers.

Is the round down what you want? or just round?

If it's ROUND, then use the ROUND() Function with 100 as the second parameter.

If it's floor, you need to divide by 100, floor it, and then multiply by 100.

``````answer1 = round(original, 100);

All Replies
Solution
‎02-28-2018 02:00 PM
Super User
Posts: 24,027

## Re: Formatting numbers.

Is the round down what you want? or just round?

If it's ROUND, then use the ROUND() Function with 100 as the second parameter.

If it's floor, you need to divide by 100, floor it, and then multiply by 100.

``````answer1 = round(original, 100);

Frequent Contributor
Posts: 93

## Re: Formatting numbers.

I have small doubt on the

``answer1 = round(619, 100);answer1=600;how we are getting 600 can someone explain it...``

`I have understand in this methodx=round(223.456,.3);Result:x=223.5In the above I have understand that first step: 223.456*0.3=67.0368second step :round(67.0368)=67.368third step : 67.368/0.3=223.5`

Super User
Posts: 24,027

## Re: Formatting numbers.

@rajeshalwayswel

Rounds the first argument to the nearest multiple of the second argument, or to the nearest integer when the second argument is omitted.

So in 619, the nearest 100 is 600 and 700. Because 600 is closer, it's rounded to 600.

Your interpretation/logic appears incorrect - run the code.

first step: 223.456*0.3=67.0368
second step :round(67.0368)=67.368 -> This would result in 67, not 67.368.
third step : 67.368/0.3=223.5

My interpretation was always, figure out how many exact values of the second parameter fit in and then round up or down as necessary.

The logic in my head is, assuming ROUND(P1, P2) is equivalent to:

Value = round(P1/P2,1) * P2 ;

At least for positive values. Here's some demo code that can help illustrate this.

``````data demo;
x=round(223.456, .3);
y=223.456/0.3;
z=round(y, 1);
w=z*0.3;
x1=round(67.0368);
test=round(223.456/0.3)*0.3;
test2=round(619, 100);
run;``````

rajeshalwayswel wrote:

I have small doubt on the

``answer1 = round(619, 100);answer1=600;how we are getting 600 can someone explain it...``

`I have understand in this methodx=round(223.456,.3);Result:x=223.5In the above I have understand that first step: 223.456*0.3=67.0368second step :round(67.0368)=67.368third step : 67.368/0.3=223.5`

Frequent Contributor
Posts: 93

## Re: Formatting numbers.

Thank you.. It very clear..

☑ This topic is solved.