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
- /
- Round function

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-04-2017 03:30 PM - last edited on 07-04-2017 03:35 PM by Reeza

value=round(3.340422,1.5);

its not round to 3.58 .

could you plz help me by use round to get around 3.58 value in that statement.

Accepted Solutions

Solution

07-04-2017
03:52 PM

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

Posted in reply to vinod4842

07-04-2017 03:48 PM

Note that the second parameter is supposed to be the multiple you want. Ie you want 3.34... rounded to the nearest 1.5.

Multiples of 1.5 are 0, 1.5, 3, 4.5 so the result will be 3.

If you want values of 3.58 you need to have some multiple of that number. So dividing it by 2, gives 1.79.

Multiples of 1.79 are 0, 1.79, 3.58 and 3.34 will round to 3.58.

However, I'm having a hard time seeing how this is actually what you would want. But it will answer the question you've asked.

`X = round(3.340422, 1.79);`

All Replies

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

Posted in reply to vinod4842

07-04-2017 03:40 PM

@vinod4842 Note that I've modified your subject line to Round as it's slightly more descriptive than 'SAS'. Please recall that our goal on here is to both answer your question and future users.

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

Posted in reply to Reeza

07-04-2017 03:49 PM

data ds;

infile datalines;

input ID CASH_TURNOVER COUNTRY;

CASH_TURNOVER=round(CASH_TURNOVER,);

DATALINES;

702272 3.340422 IND

705651 2.371976 IND

;

RUN;

I WANT TO CHANGE THE CASH_TURNOVER VARIABLE FIRST VALUE TO 3.58, WHAT CAN I DO WITH THAT ROUND OPTION

I GETTING SO MANY GARBAGE VALUE.

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

Posted in reply to vinod4842

07-04-2017 03:51 PM

vinod4842 wrote:

I WANT TO CHANGE THE CASH_TURNOVER VARIABLE FIRST VALUE TO 3.58, WHAT CAN I DO WITH THAT ROUND OPTION

I GETTING SO MANY GARBAGE VALUE.

WHAT'S THE RULE? WHY IS IT 3.58 AND NOT 3.59, OR 3.78?

Solution

07-04-2017
03:52 PM

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

Posted in reply to vinod4842

07-04-2017 03:48 PM

Note that the second parameter is supposed to be the multiple you want. Ie you want 3.34... rounded to the nearest 1.5.

Multiples of 1.5 are 0, 1.5, 3, 4.5 so the result will be 3.

If you want values of 3.58 you need to have some multiple of that number. So dividing it by 2, gives 1.79.

Multiples of 1.79 are 0, 1.79, 3.58 and 3.34 will round to 3.58.

However, I'm having a hard time seeing how this is actually what you would want. But it will answer the question you've asked.

`X = round(3.340422, 1.79);`

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

Posted in reply to Reeza

07-04-2017 03:52 PM

thanku very much reeza