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!
%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
%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
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
tk's PG !
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.