You can use the CEIL function in SAS to return the smallest integer that is greater than or equal to some numeric value.
The following example shows how to use the CEIL function in practice.
Note: The opposite of the CEIL function in SAS is the FLOOR function.
Example: How to Use CEIL 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 print data=my_data;
We can use the CEIL function to return the smallest integer that is less than or equal to each numeric value in the avg_sales column:
/*create new dataset*/ data new_data; set my_data; ceil_avg_sales = ceil(avg_sales); run; /*view new dataset*/ proc print data=new_data;
Notice that the new column called ceil_avg_sales contains the smallest integer that is less than or equal to each numeric value in the avg_sales column.
- The value 12.30 becomes 13.
- The value 14.50 becomes 15.
- The value 8.44 becomes 9.
- The value 12.87 becomes 13.
And so on.
The following tutorials explain how to perform other common tasks in SAS: