When I make a format, about 99.9% of the time I expect it to be exhaustive of the values that will be encountered. It would be nice to be able to define a format that would throw an error to the log if a value was not found.
For example:
proc format;
value sex
1='F'
2='M'
other=_ERROR_ /*pseudo code*/
;
run;
data have;
input sex ;
cards;
1
1
3
;
run;
When the format is used, it would throw an error to the log. So below PROC step and DATA step would both throw errors, ideally listing the invalid value:
proc freq data=have;
tables sex;
format sex sex.;
run;
data want;
set have;
sexC=put(sex,sex.);
run;
I know there are alternatives, e.g.,
data want;
set have;
sexC=put(sex,sex.);
if sexC="_ERROR_" then put "ERROR: invalid value " sex=;
run;
But it would be nice to have a way to say when a format is created, "if any value is outside the domain of values defined in the format, throw an error [or warning or note]."