Table of Contents
The FLOOR function in SAS is a mathematical function that allows users to round down a numeric value to the nearest whole number. This function is particularly useful in data analysis and reporting, as it helps to simplify numeric values and make them more easily understandable. To use the FLOOR function, simply input the desired numeric value as an argument and the function will return the rounded down value. This function can be applied to a single value or to an entire column of data in SAS. It is a valuable tool for data manipulation and simplification in SAS programming.
Use the FLOOR Function in SAS
You can use the FLOOR function in SAS to return the largest integer less than or equal to some numeric value.
The following example shows how to use the FLOOR function in practice.
Note: The opposite of the FLOOR function in SAS is the function.
Example: How to Use FLOOR Function in SAS
Suppose we have the following dataset in SAS that contains information about the average items sold by various employees at some company:
/*create dataset*/
data my_data;
input employee $ avg_sales;
datalines;
Andy 12.3
Bob 14.5
Chad 8.44
Derrick 12.87
Eric 8.01
Frank 10
George 11.5
Henry 11.99
Isaac 7.64
;
run;
/*view dataset*/
proc printdata=my_data;

We can use the FLOOR function to return the largest integer less than or equal to each numeric value in the avg_sales column:
/*create new dataset*/
data new_data;
set my_data;
floor_avg_sales = floor(avg_sales);
run;
/*view new dataset*/
proc printdata=new_data;

Notice that the new column called floor_avg_sales contains the largest integer less than or equal to each numeric value in the avg_sales column.
For example:
- The value 12.30 becomes 12.
- The value 14.50 becomes 14.
- The value 8.44 becomes 8.
- The value 12.87 becomes 12.
And so on.
The Difference Between FLOOR vs INT Functions
The INT function in SAS returns the whole number portion of numeric values.
For positive values, the FLOOR and INT functions will return the exact same numbers.
Consider the following dataset as an example:
/*create dataset*/ data my_data; input employee $ avg_sales; datalines; Andy 12.3 Bob 14.5 Chad 8.44 Derrick -12.87 Eric -8.01 /*create new dataset*/ data new_data; set my_data; floor_avg_sales = floor(avg_sales); int_avg_sales = int(avg_sales); run; /*view new dataset*/ proc printdata=new_data;

For positive numeric values, the FLOOR and INT functions return the same results.
However, they don’t return the same results for negative numeric values.
The FLOOR function essentially rounds negative numbers down to the next integer while the INT function rounds negative numbers up to the next integer.
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
stats writer (2024). How can I use the FLOOR function in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-the-floor-function-in-sas/
stats writer. "How can I use the FLOOR function in SAS?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-the-floor-function-in-sas/.
stats writer. "How can I use the FLOOR function in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-the-floor-function-in-sas/.
stats writer (2024) 'How can I use the FLOOR function in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-the-floor-function-in-sas/.
[1] stats writer, "How can I use the FLOOR function in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I use the FLOOR function in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
