fix(blog): the range rules compare in SAS's own order

A range rule keys both sides into the order SAS uses for a numeric variable, so a
range written in special missings means what SAS would mean by it: MINVAL .A with
MAXVAL .C accepts .B and rejects .D, a blank fails a floor of .A, and a number
sits above every missing - passing a floor of .A and failing a ceiling of .C.
Against a numeric bound the same order gives the obvious answer: a missing fails
MINVAL 1 and passes MAXVAL 100.

Replaces the "the range rules step aside for a missing value" wording.
This commit is contained in:
dc
2026-09-23 21:27:58 +00:00
parent bbd5793d8b
commit 0b18658686
+7 -6
View File
@@ -53,10 +53,12 @@ These are Data Controller's own rules, configured per column in the `MPE_VALIDAT
- `SOFTSELECT` / `HARDSELECT` - both support special missings; a soft dropdown never blocks a value, and a hard one lists them alongside the ordinary values
- `ROUND` - harmless. It only rounds values that are numbers, so a special missing is left exactly as it was typed
The range rules step aside for a missing value, because a missing is not a number for a minimum or a maximum to apply to:
The range rules compare in the order SAS itself uses, which is what makes them interesting here. SAS puts every missing below every non-missing value, and orders the missing values among themselves: `._` is the lowest, then the regular missing, then `.A` through `.Z`. So a range can be written in special missings and mean exactly what SAS would mean by it:
- `MINVAL` / `MAXVAL` - both accept a special missing, and both still reject a real number that is out of range. Use `NOTNULL` if the column has to be populated; a range rule alone leaves the column free to hold a missing
- The rule's own value has to be a number: put a special missing in `MINVAL` and every real number in the column fails, and the same in `MAXVAL` - a rule value that is not a number leaves nothing for a value to pass
- `MINVAL .A` with `MAXVAL .C` accepts `.B` and rejects `.D`, and a blank - the regular missing - fails that floor because it sorts below `.A`
- a number sits above every missing, so it passes a floor of `.A` and fails a ceiling of `.C`
- against a numeric bound the ordering does the obvious thing: a missing sorts below every number, so it fails a `MINVAL` of 1 and passes a `MAXVAL` of 100. Use `NOTNULL` if the column has to be populated
- a rule value that is neither a number nor a special missing - a typo such as `..` or `AB` - satisfies nothing, so the column fails until the rule is corrected
A formula is the one case where a special missing genuinely does not work:
@@ -106,12 +108,11 @@ How they behave in Data Controller's validation rules:
- SOFTSELECT and HARDSELECT both support them
- ROUND leaves it alone, because it only rounds numbers
The range rules step aside for one - a missing is not a number for a minimum or a maximum to apply to:
The range rules compare in SAS's own order, so a range can be written in special missings: MINVAL .A with MAXVAL .C accepts .B and rejects .D. A missing sorts below every number, so it fails a numeric MINVAL and passes a numeric MAXVAL; a number sits above every missing.
- MINVAL and MAXVAL both accept it, and both still reject a real number that is out of range; use NOTNULL if the column must be populated
- a HARDFORMULA/SOFTFORMULA that reads a special-missing cell returns #VALUE! rather than a number
In short: a value for the pattern and dropdown rules, a missing value for anything that wants a number.
In short: a value for the pattern and dropdown rules, and a value with its own place in the order for the range rules.
The video shows the whole cycle - entering them, the rejections, submit, approve, and the DIFF.