In reply to FreelanceReinhard.

The LAG (and DIF) functions are handled differently than most other SAS functions because they need to maintain a memory queue and therefore (to work correctly) need to be called on every observation. If someone is trying to understand short circuiting, I would suggest they start with simple regular functions, not LAG.

When I use the LAG function and complex logical conditions, I assign the lagged value to a variable (L1 = lag(X)) and then perform logical operations with the variable. If you do this, I think both LAG and short-circuiting perform as you expect them to.