I'm trying to create a proc format that reads in postcodes and applies a label to its state accordingly.
For some reason, despite both my start and end fields being numeric, it keeps returning an error saying that:
"The format ZONENEW was not found or could not be loaded."
The only work around I've figured out is to change my Pcode data to Text, and my Start and End format fields as Text as well.
This is my existing code, still in its numeric formatting.
data Fmt_All_zones;
set all_zones end=eof;
retain type 'c';
fmtname = 'zonenew';
start = pcode_fr;
end = pcode_to;
label = key;
output;
if eof then do;
start = 'other';
end = 'other';
label = "Error";
output;
end;
run;
proc format cntlin = fmt_all_zones library = work;
run;
data TestPostcodes;
input Pcode;
datalines;
2050
2065
3000
2879
9999
1999
6488
;
run;
data FilteredPcode;
set TestPostcodes;
Pcode_Label = put(Pcode, zonenew.);
run;
I would appreciate an explanation to help my conceptual understanding of the process! Thanks.
You defined a character format by setting
TYPE='C'
. If you want an numeric format then useTYPE='N'
.