How can the CEIL function be used in SAS? 2

How can the CEIL function be used in SAS?

The CEIL function in SAS is used to round up a numeric value to the nearest integer. This function takes one argument, which is the numeric value to be rounded. It is useful in situations where precise integer values are required, such as in financial calculations or for generating report data. The result of the CEIL function is always an integer, and it follows the standard rounding rules where a value of 0.5 or higher is rounded up to the next integer. It can be used in conjunction with other SAS functions and statements to manipulate data and perform various calculations. Overall, the CEIL function provides a convenient and efficient way to round up numeric values in SAS programming.

Use the CEIL Function in SAS


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 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 printdata=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 printdata=new_data;

SAS CEIL function example

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.

For example:

  • 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:

Cite this article

stats writer (2024). How can the CEIL function be used in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-the-ceil-function-be-used-in-sas/

stats writer. "How can the CEIL function be used in SAS?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-the-ceil-function-be-used-in-sas/.

stats writer. "How can the CEIL function be used in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-the-ceil-function-be-used-in-sas/.

stats writer (2024) 'How can the CEIL function be used in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-the-ceil-function-be-used-in-sas/.

[1] stats writer, "How can the CEIL function be used in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can the CEIL function be used in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top