Hi, I'm sorry I guess I pasted the wrong version. "desc" only contains the name of the last product but your desired output is supposed to be in "result". The reason why it is empty/buggy is because there is no handling of blank padding thus at every loop iteration, the concatenation was trying to concatenate 500 blanks with whatever additionnal info and truncating to the 500 blanks. Here's the fixed version without removal of the ending comma atm although that isn't overly complicated to add. data want; length id $1. count $1. desc $20. result $500.; if _N_=1 then do; declare hash myhash(dataset: 'lookuptable'); myhash.defineKey('id'); myhash.defineData('desc'); myhash.defineDone(); end; set have; do i=1 to 4; /* taking advantage of fixed length and 24 different codes - here only 4 for the example data */ id = substr(string, i*2-1, 1); count = substr(string, i*2, 1); if count NE "0" then do; myhash.find(); result=cat(trim(result), trim(desc), " ", trim(count), ","); end; end; drop desc count i id; run; Sorry about that. Vincent
... View more