@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".
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)?
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 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".
@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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.