BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
unnati
Obsidian | Level 7
How to round down a number by 2 decimal point. For example I have the value of x= 27.396326559 . How to round this value to x=27.44

Many thanks
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@unnati wrote:
Yes. I want to round up. In your solution you round up to 27.40. Is it possible to round up it to 27.44 for value mentioned in question ?? I think 27.44 is error but need second opinion .

Round up gives you 27.4. The words "round up" do not seem to me to ever have the interpretation that you want to "round up" 27.396326559 to get 27.44.

 

I'm sure you could invent some rules that turn 27.396326559 into 27.44, but without such rules, it doesn't fit the clearly understood meaning of "round up".

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Is that a typo? Do you want 27.4 or 27.44?

 

Why does your title ask about rounding up and your text talk about rounding down (even though it seems you are rounding up)?

--
Paige Miller
Tom
Super User Tom
Super User

Is there a typo in your question?  Did you mean 27.40 ?


You can use the ROUND() function to round to closest multiple of any number.  So using ROUND(x,0.01) will round your example to 27.40.

 

Do you want to always round up?  So that values between 27.390 and 27.395, exclusive, will also  round to 27.40 instead of 27.39?  Try CEIL(x*100)/100.

unnati
Obsidian | Level 7
Yes. I want to round up. In your solution you round up to 27.40. Is it possible to round up it to 27.44 for value mentioned in question ?? I think 27.44 is error but need second opinion .
PaigeMiller
Diamond | Level 26

@unnati wrote:
Yes. I want to round up. In your solution you round up to 27.40. Is it possible to round up it to 27.44 for value mentioned in question ?? I think 27.44 is error but need second opinion .

Round up gives you 27.4. The words "round up" do not seem to me to ever have the interpretation that you want to "round up" 27.396326559 to get 27.44.

 

I'm sure you could invent some rules that turn 27.396326559 into 27.44, but without such rules, it doesn't fit the clearly understood meaning of "round up".

--
Paige Miller
ballardw
Super User

@unnati wrote:
How to round down a number by 2 decimal point. For example I have the value of x= 27.396326559 . How to round this value to x=27.44

Many thanks

Is this the ONLY value you need to change or are there many? Your result is very atypical of "rounding" and if you have multiple values that are not actually rounding like this then we need other examples.

If this is the only value that needs to change then

 

if x = 27.396326559 then x=27.44;

might be the approach.

 

Otherwise describe your rules in more detail. Typically rounding that value to 2 decimals would be 27.40 (rounded to nearest 0.01). Your result looks a lot like some very old very lazy coding that would add 0.05 to every thing and then truncate digits. But that isn't really rounding and when used would have been the approach to round to one decimal place, i.e. 27.4.

Reeza
Super User
There are no logical/systematic rules that would round 27.3963 to 27.44 so the rules to do so are custom rules. You would need to tell us what those rules are how and how that conversion would work for us to code that. I mean I can make it but not using any round/floor/ceiling function.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 989 views
  • 5 likes
  • 5 in conversation