|
Macros for SAS Application Developers
https://github.com/sasjs/core |
Assert model and optionally check key under OBS= and FIRSTOBS=. More...
Go to the source code of this file.
Compares column names, types and lengths exactly, independent of column order, case, formats and labels. The model dataset can be empty. When key= is supplied and columns match, key components must be nonmissing and composite keys unique within the caller's OBS= and FIRSTOBS= limits. Limits can hide missing or duplicate keys. A blank key= skips key validation. An empty dataset has no duplicate or missing keys.
One PASS or FAIL row is appended to outds. Missing datasets and invalid key columns produce FAIL. The macro does not sort or intentionally modify inputs. SASAUTOS installations must include the ddl folder for mddl_assert. Dataset names must use ordinary V7 member names, not name literals. Unqualified dataset names refer to WORK. OUTDS must identify a distinct dataset and must not alias either input through a libref, filesystem link, view or other storage mapping. Dataset options are not accepted. Direct overlaps, malformed dataset names and name literals are rejected with a diagnostic in the SAS log and nonzero SYSCC, without appending a result row. Physical aliases are not detected.
Example:
%mp_assertmodel(work.actual,base=work.expected,key=id region, desc=Checking the output model)
| [in] | inds | Input dataset to check |
| [in] | base= | Reference dataset defining the expected columns |
| [in] | key= | Space-separated V7 key columns checked within OBS= and FIRSTOBS= limits; blank skips key validation |
| [in] | desc= | (Testing dataset model) Description for the result row |
| [out] | outds= | (work.test_results) Assertion results dataset |
Definition in file mp_assertmodel.sas.