A little announcement. A lot to explore.

Happy learning!

Explore lessons, including SAS & R programs and practice data.

Search lessons

Type at least 3 characters to see matching lessons.

Open SAS ↗Open R ↗
← SASnRRound Numeric Values

Introduction

  • Rounding is a daily need in report layout and derived-variable building — to an integer, to a decimal place, up to the next integer, down to the previous one.
  • Four common asks: round to nearest integer, round to a decimal place, ceiling, and floor.
  • SAS offers round(value) for nearest integer, round(value, 0.01) for a decimal place, and ceil / floor for directional rounding.
  • R uses round() with an optional digits argument, plus ceiling() and floor().
  • A subtle difference: R's round() uses banker's rounding (round-half-to-even), whereas SAS rounds half up.
  • This lesson rounds a short vector that includes 1.5 and -4.75 so the half-case difference becomes visible.

Round Numeric Values