Rounding is one of the first concepts we learn in math. It’s so familiar that most of us stop thinking about it entirely. But in clinical programming, where a single decimal place can determine whether a subject meets a criterion or whether two independent programs compare cleanly, rounding deserves a second look.
Imagine this scenario. You’re deriving percent change from baseline for a clinical endpoint. The calculation is straightforward, your code matches the specification, and the output looks exactly as expected. Later in the program, you assign a responder flag whenever the percent change equals -100.
Everything should work. Except it doesn’t.
Five subjects who should be responders aren’t flagged. You double check the derivation. You review the specification. You rerun the program. Nothing changes. The listing clearly displays
-100, but SAS insists the value isn’t equal to -100. At first glance, it feels like a programming bug. In reality, it’s something much more fundamental.
The Hidden Reality of Floating-Point Numbers
Every major language we use in clinical programming, including SAS, R, Python, and even Excel, stores numeric values using the IEEE-754 double-precision floating-point standard.
The catch is that most decimal numbers can’t be represented exactly in binary. A value like 0.1 is already an approximation the moment it’s stored in the computer system. Normally, those approximations are so small that they don’t matter. But after multiple calculations, unit conversions, or simply evaluating expressions in different orders, tiny differences can accumulate in the fifteenth or sixteenth decimal place. You’ll never see those differences in a standard numeric format. Your program, however, certainly will. That’s why two values that both display as -100 may not actually be identical when compared internally.
Why This Matters
This isn’t just an interesting computer science fact. It has real implications for clinical trials.
One of my favorite presentations from PharmaSUG 2026 was the Best Paper by Jennifer McGrogan and Mario Widel, The Problems Surrounding Rounding (AP-108). Their examples highlight just how easily floating-point precision can affect everyday programming.
In one demonstration, adding the same four numbers in different orders produced different stored results across every language they tested. Mathematically, the expressions are identical. Computationally, they are not.
Another example was even more striking. A laboratory value was converted from mmol/L to mg/dL and then rounded. That small change was enough to move the result across a CTCAE grading threshold, changing what would have been a Grade 3 adverse event into a Grade 4. No one changed the data intentionally. The calculation itself introduced the difference.
These aren’t obscure edge cases. They are the kinds of derivations clinical programmers perform every day.
A Few Simple Practices Can Prevent Big Headaches
Fortunately, avoiding these issues doesn’t require complicated solutions. One simple habit is using parentheses to explicitly control the order of operations. Consider these two expressions:
- (CHG / BASE) * 100
- 100 * CHG / BASE
Mathematically, they’re equivalent. Internally, however, SAS evaluates expressions from left to right, so the intermediate calculations can produce slightly different stored values.
Another recommendation is to avoid checking derived values for exact equality. Instead of asking whether a calculated value is exactly -100, round the result to the required precision before applying responder logic or threshold criteria.
And when a comparison fails even though the numbers appear identical, SAS provides a useful debugging tool. Applying the HEX16. format reveals the actual stored value, making it much easier to determine whether you’re dealing with floating-point precision or a genuine programming error.
It’s Also a Specification Issue
Floating-point precision isn’t only something programmers should think about. It also has implications for data specifications.
If an ADaM specification defines a threshold such as a 100% reduction from baseline, it’s worth stating the precision at which that comparison should be made before the determination of the flag. Without guidance, independent programmers may handle precision differently, leading to discrepancies that are difficult to diagnose.
Similarly, the PhUSE working group’s guidance recommends storing the derived values without rounding in variables like AVAL, because storing a rounded value sacrifices precision that downstream calculations may need. The two recommendations work together: retain full precision in the dataset and define the precision for flag determination at the specification level and display rounding at the table shell level.