Hello,
I need to know if SAS EG has the capabilities of rounding up to the third decimal place if there is a fourth numeric value when doing the division? I understand the round/ceil/floor functions but I'm not getting the expected results.
Data:
17/30 = .5666666666666667 = output = .567 (correct)
1/30 = .03333333333333 = output = .033 (incorrect) wanting output to be .034
I understand the ROUND function is working properly but I'm needing the third decimal to round up if there is a 4th value period.
This is currently what is coded:
ROUND(((INPUT(t1.'QUANTITY LIMIT AMOUNT'n, best10.))/(INPUT(t1.'QUANTITY LIMIT DAYS'n, best10.))),0.001
Ignoring all of the INPUT stuff try:
(ceil(round( 1/30 ,0.0001)*1000))/1000
CEIL and FLOOR result in integer values, so you need to do the decimal positioning manually when using a non-standard "rounding" approach.
Ignoring all of the INPUT stuff try:
(ceil(round( 1/30 ,0.0001)*1000))/1000
CEIL and FLOOR result in integer values, so you need to do the decimal positioning manually when using a non-standard "rounding" approach.
Thank you so much!! It works beautifully!
Hi @shaymo
Welcome to the community!
Here is a suggestion to round up everytime:
%let decimal = 1000;
data have;
var1_notrounded = (17/30)*&decimal.;
var1 = ceil(var1_notrounded) / &decimal.;
var2_notrounded = (1/30)*&decimal.;
var2 = ceil(var2_notrounded) / &decimal.;
var3_notrounded = INPUT(t1.'QUANTITY LIMIT AMOUNT'n, best10.)/INPUT(t1.'QUANTITY LIMIT DAYS'n, best10.)*&decimal.;
var3 = ceil(var3_notrounded) / &decimal.;
run;
Best,
Thank you for the response! This could also work but I'm real new to SAS EG and honestly don't know how to code per your example. Appreciate your help!
You could round and if the value went down add 0.001.
data test;
input x;
y=round(x,0.001)+0.001*(round(x,0.001)<x);
cards;
.566667
.333333
;
proc print;
run;
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.