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.
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;
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;
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
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...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
Thank you.. It very clear..
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.