Rounding in SAS

There are two rounding functions in SAS.

The round() function in SAS will round to the nearest whole number and ‘away from zero’ or ‘rounding up’ when equidistant meaning that exactly 12.5 rounds to the integer 13.

The rounde() function in SAS will round to the nearest whole number and ‘rounding to the even number’ when equidistant, meaning that exactly 12.5 rounds to the integer 12.

Both functions allow you to specify the number of decimal places you want to round to.

For example (See references for source of the example)

    #Example code
    data XXX;
      my_number=2.2; output;
      my_number=3.99; output;
      my_number=1.2345; output;
      my_number=7.876; output;
      my_number=13.8739;  output;
    run;

    data xxx2;
      set xxx;
        r_1_dec = round(my_number, 0.1);
        r_2_dec = round(my_number, 0.01);
        r_3_dec = round(my_number, 0.001);
        
        re_1_dec = rounde(my_number, 0.1);
        re_2_dec = rounde(my_number, 0.01);
        re_3_dec = rounde(my_number, 0.001);
    run;
my_number r_1_dec r_2_de r_3_dec re_1_dec re_2_dec re_3_dec
2.2 2.2 2.2 2.2 2.2 2.2 2.2
3.99 4 3.99 3.99 4 3.99 3.99
1.2345 1.2 1.23 1.235 1.2 1.23 1.234
7.876 7.9 7.88 7.876 7.9 7.88 7.876
13.8739 13.9 13.87 13.874 13.9 13.87 13.874

References

How to Round Numbers in SAS - SAS Example Code