- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.