Ceil or Round up, Floor or Round down, Round off in SAS

Round up in SAS or ceil in SAS uses ceil() function which rounds up the column in SAS. Round down in SAS or floor in SAS uses floor() function which rounds down the column in SAS.  Round off the column in SAS is accomplished by round() function. Let’s see an example of each.

  • Round up or Ceil in SAS using ceil() function
  • Round down or floor in SAS using floor() function
  • Round off the column in SAS using round() function
  • Round off to decimal places in SAS

So we will be using CARS Table in our example

Ceil or Round up, Floor or Round down, Round off in SAS 1

 

 

Round down in SAS – FLOOR

Syntax:

 floor(‘colname1’)

colname1 – Column name

floor() Function in SAS takes up the column name as argument and rounds down the column

/* round down - floor */ 

data city_new; 
set city; 
floor_temp = floor(Temperature); 
run; 


floor of “Temperature” is shown below

Ceil or Round up, Floor or Round down, Round off in SAS 2

 

 

Round up in SAS – CEIL

Syntax:

 ceil(‘colname1’)

colname1 – Column name

ceil() Function in SAS takes up the column name as argument and rounds up the column.

/* round up - ceil */ 

data city_new; 
set city; 
ceil_temp = ceil(Temperature); 
run; 

ceil of “Temperature” is shown below
Ceil or Round up, Floor or Round down, Round off in SAS 3

 

 

Round off in SAS – round to nearest integer

Syntax:

 round(‘colname1’,n)

colname1 – Column name
n – round to n decimal places

round() Function in SAS takes up the column name as argument and rounds the column to nearest integers

/* round  - round off; round to nearest integer */

data city_new; 
set city; 
round_temp = round(Temperature); 
round_temp_near2decimal=round(Temperature,0.01); 
round_temp_near1decimal=round(Temperature,0.1); 
round_temp_near10= round(Temperature,10); 
run;

rounding off of “Temperature” column to nearest  1 decimal.2 decimal and 10 digit is shown below
Ceil or Round up, Floor or Round down, Round off in SAS 4