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 ↗
← SASnRApply Basic Numeric Functions

Introduction

  • Basic numeric functions — round, ceil, floor, truncate, absolute value, modulo — show up everywhere in data manipulation, from banding continuous scores to building derived flags.
  • Most SAS numeric functions have direct analogues in R, with one notable exception: the sign convention for the modulo operator differs between SAS and R.
  • SAS offers ROUND, CEIL, FLOOR, INT, ABS, and MOD.
  • R offers round, ceiling, floor, trunc, abs, and %% (with a small helper needed to match SAS MOD).
  • This lesson applies each function to a vector that includes negative values, a zero, and positive fractions, so edge cases are easy to see.
  • Pay particular attention to the two modulo columns — they only diverge on negative numerators, which is exactly where the two conventions disagree.

Apply Basic Numeric Functions