SAS (Base SAS)+
data numbers;
input num;
round_val = round(num);
ceil_val = ceil(num);
floor_val = floor(num);
int_val = int(num);
abs_val = abs(num);
mod_val = mod(num, 3);
datalines;
-2.51
-1.2
0
1.3
2.7
;
run;- This lesson walks through the most common SAS numeric functions applied to a small vector of floats.
ROUND(num)rounds to the nearest whole number using half-up banker rounding.CEIL(num)rounds up towards positive infinity — always gives the next integer at or above the value.FLOOR(num)rounds down towards negative infinity — always gives the next integer at or below the value.INT(num)truncates towards zero — drops the fractional part without rounding.ABS(num)returns the magnitude, always non-negative.MOD(num, 3)returns the remainder after integer division by 3, with the same sign as the numerator.- After running, we inspect the
numbersdataset and confirm each derived column reflects the expected rounding or remainder rule. - Useful for building derived flags (for example, rounding a continuous age to a whole number) or for arithmetic grouping.