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.

 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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