"ERROR: Invalid value for width specified - width out of range"
The code that generated it was using SQL and the PUT function to convert an ID using a format, like so:
compress(put(id, idfmt.), '. ')
Where the IDFMT format originated as a user-created format, stored in a data set. The quick and dirty solution is to add the "?" modifier to the PUT function, which is oddly documented on the INPUT function but not the PUT function:
compress(put(id, ? idfmt.), '. ')
Now why wouldn't that be documented on the PUT function page?
And what about my original problem? I've tried varying the lengths of the input column, the format, removing the compress statement, and switching to TRANWRD or PRXCHANGE. I also tried to identify the records involved, but with 35.6 million records, that was far to slow. I know that the issue occurred in the second half of the data, but beyond that is too time consuming to look for the needle in the haystack.
Finally, I figured out a solution: The original format is based on an input data set, using the CNTLIN= option on PROC FORMAT to generate the format on the fly. The data set does not have the HLO (High/Low/Other) flag to indicate what non-matching (Other) starting values would be labeled as. I added it like so:
data custom_format;
/* Output the original records */
set custom_format end=end;
output;
set custom_format end=end;
output;
/* Output an additional record */
if end then do;
start=.;
label=.;
fmtname='idfmt';
hlo='O';
output;
end;
run;
if end then do;
start=.;
label=.;
fmtname='idfmt';
hlo='O';
output;
end;
run;
Then the code using the format worked, and to boot it no longer needed the COMPRESS function to remove the blanks and numeric missing values (".").
Hopefully anyone else with a similar issue will find that one of the above solutions fits their need.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.