One of my colleagues is developing code to create a format for all of the
valid values on the mainframe, and assign it a numeric key, starting with
one. To eliminate noise, she wants to get rid of everything that doesn't
match her format. She wrote this code, but the results were not as
expected. We expected one good value and one bad value, but instead both
values passed the format. Take a look. I know its Friday and you were
looking for OT Friday humor, but I think its important to be aware of this
Here's the code - you can run it yourself. Version 9.1.3 I've solved the
problem and when you all finish wrassling with it I'll explain.
length mf_item_code $13.
mf_item_code = '1311--AD13I01';
item_sid = 1;
DATA ITEM_REF ;
LENGTH start end $13 ;
PROC format cntlin=ITEM_REF;
length item_code $13.
item_code = '1311--AC13I99'; output;
item_code = '1311--AD13I01'; output;
data item_w_sid item_err;
item_sid = input(put(item_code, $items.),best.) ;
if missing(item_sid) then
proc print data=item_w_sid;
and Here's the results...
28 data item_w_sid item_err;
29 set item;
30 item_sid = input(put(item_code, $items.),best.) ;
31 if missing(item_sid) then
32 output item_err;
34 output item_w_sid;
NOTE: There were 2 observations read from the data set WORK.ITEM.
NOTE: The data set WORK.ITEM_W_SID has 2 observations and 2 variables.
NOTE: The data set WORK.ITEM_ERR has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.00 seconds
Dianne Rhodes @ bls