Skip to main content

Comparison methodology

Every number on this site comes from running SAS and R on the same inputs.

The goal of each comparison is to answer one question: if you replace this SAS code with the R code, do your results change?

The method

  1. Run SAS on many inputs. Each comparison starts with a SAS program that covers far more cases than a typical analysis: every combination of a grid of inputs, plus hand-picked edge cases. SAS saves the results in .sas7bdat files.
  2. Run R on the same inputs. R reads the SAS data sets with haven::read_sas(). A .sas7bdat file stores numbers as 8-byte doubles, so R gets the exact same bits that SAS used. We don’t use CSV files, because writing a number as text and reading it back can change its last digits.
  3. Compare every result. We report how many results are identical, and how large the differences are when they are not. When a difference has a cause, such as a different definition of a p-value, the comparison page explains it.

Versions

SAS SAS Viya V.04.00M0P060826, run from SAS Studio, Linux X64
SAS options DECIMALCONV=COMPATIBLE (the default) unless a page says otherwise
R R 4.6.1, on Apple Silicon (aarch64)
segue the version on GitHub when the page was built

The R code on each page runs when the site is built, so the R output you see comes from the current version of segue.

What “agree” means

Floating-point results can differ in the last few bits for reasons that don’t matter, such as adding numbers in a different order. So each page reports what it can:

  • Identical: the same double, bit for bit. We use this for functions such as sas_round(), where the goal is to reproduce SAS exactly.
  • Largest difference: the biggest absolute difference between the R and SAS values. We use this for statistical tests, where both programs compute the same formula with their own numerical code. A difference of about 1e-15 is the rounding error of a double.

Get segue

# install.packages("pak")
pak::pak("posit-dev/segue")