turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Formatting numbers.

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-28-2018 01:42 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to thepushkarsingh

02-28-2018 01:46 PM

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);
answer2 = floor(original/100)*100;
```

All Replies

Solution

02-28-2018
02:00 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to thepushkarsingh

02-28-2018 01:46 PM

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);
answer2 = floor(original/100)*100;
```

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

02-28-2018 05:59 PM

I have small doubt on the

`answer1 = round(619, 100);`

answer1=600;

how we are getting 600 can someone explain it...

can you please explain it..

I have understand in this method

x=round(223.456,.3);

Result:

x=223.5

In the above I have understand that

first step: 223.456*0.3=67.0368

second step :round(67.0368)=67.368

third step : 67.368/0.3=223.5

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to rajeshalwayswel

02-28-2018 09:36 PM

Rounds the first argument to the

nearest multiple of the second argument,orto the nearest integerwhen 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...can you please explain it..

I have understand in this method

x=round(223.456,.3);

Result:

x=223.5

In the above I have understand that

first step: 223.456*0.3=67.0368

second step :round(67.0368)=67.368

third step : 67.368/0.3=223.5

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-01-2018 12:36 PM

Thank you.. It very clear..