FLOOR function returns the largest integer that is less than or equal to the argument while INT function removes any values after the decimal places.
So in terms of the final result, ain't they exact the same? Are there any situations where you should one function over the other?
see example with sashelp.tourism
data temp; set sashelp.tourism; floor = floor(vsp); int = int(vsp); run; proc print data=temp; var vsp floor int; run;
No. Consider the case of negative numbers. In that case, the results will differ
data have;
do _N_ = 1 to 10;
x = rand('uniform', -10, 10);
output;
end;
format x 8.2;
run;
data want;
set have;
int = int(x);
floor = floor(x);
run;
According to the INT documentation (which you should be reading before you ask, @Nietzsche)
The INT function returns the integer portion of the argument (truncates the decimal portion). If the argument's value is within 1E-12 of an integer, the function results in that integer. If the value of argument is positive, the INT function has the same result as the FLOOR function. If the value of argument is negative, the INT function has the same result as the CEIL function.
@PeterClemmensen has given the most important difference. For more information about various ways to round numbers in SAS, see "Rounding up, rounding down."
Engineers often use a method known as the round-to-even method, which is also supported in SAS.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.