The SAS Output Delivery System and reporting techniques

round up every time

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

round up every time

Hello everbody!!

Is there a SAS function to round a number up?  The round() function

seems to round the number up or down depending on the rounding unit.

     round(233, 100);   ** will return 200;

     round(250, 100);   ** will return 300;

     This is what I want:

     round (233, 100);  ** will return 300;

     round (250, 100);  ** will return 300;

tk's in advanced!


Accepted Solutions
Solution
‎05-11-2012 05:02 PM
Respected Advisor
Posts: 4,651

Re: round up every time

%let unit=100;

* All you can do is :

data _null_;

up = &unit*CEIL(233/&unit);

down = &unit*FLOOR(255/&unit);

put down= up=;

run;

PG

PG

View solution in original post


All Replies
Solution
‎05-11-2012 05:02 PM
Respected Advisor
Posts: 4,651

Re: round up every time

%let unit=100;

* All you can do is :

data _null_;

up = &unit*CEIL(233/&unit);

down = &unit*FLOOR(255/&unit);

put down= up=;

run;

PG

PG
Respected Advisor
Posts: 4,651

Re: round up every time

Or you can define your own...


proc fcmp outlib=sasuser.mysubs.math;
function upround(x, unit);
return (unit*CEIL(x/unit));
endsub;
function downround(x, unit);
return (unit*FLOOR(x/unit));
endsub;
run;

options cmplib=sasuser.mySubs;

data _null_;
up = upRound(233,100);
down = downRound(255,100);
put down= up=;
run;

PG

PG
Contributor
Posts: 46

Re: round up every time

tk's PG !

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 2087 views
  • 3 likes
  • 2 in conversation