BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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;
1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

@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:

round.PNG

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

@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:

round.PNG

ballardw
Super User

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.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 4549 views
  • 0 likes
  • 3 in conversation