Hello
I want to round numbers to close 100.
This program work fine but there are few problems:
number 750 should be rounded to 800
number 126750 should be rounded to 126800
What is the way to get correct round numbers as m requested
data t;
input x;
cards;
640
751
750
382640
41864
126750
;
run;
data new;
set t;
x_new=round(x,100);
run;
@Ronein wrote:
Hello
I want to round numbers to close 100.
This program work fine but there are few problems:
number 750 should be rounded to 800
number 126750 should be rounded to 126800
What is the way to get correct round numbers as m requested
i don't see a problem:
@Ronein wrote:
Hello
I want to round numbers to close 100.
This program work fine but there are few problems:
number 750 should be rounded to 800
number 126750 should be rounded to 126800
What is the way to get correct round numbers as m requested
i don't see a problem:
One thing to be careful of when examining some of the results of functions is to make sure that you know the value of the variable. If you look at a result and see "750" where you think the round should give you "800" but the result is "700" then you need to consider that the format for the variable may be hiding something from you.
data example; input x; rndx = round(x,100); format x f3.; datalines; 749.856 750.111 ; proc print data=example; run;
So the above in the Print output will show both values of X as 750 with different rounded values because the current format only displays 3 characters and no decimals.
So if the round for your actual data appears to be off, examine the base values with a format that will display a lot of decimal places, I suggest something like BEST32.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.