A big issue from your program was already mentioned: with no errors, SQL fails to populate &msg_w. Here's a tweak that puts you on the road to accommodating that situation. Your middle DATA step is:
data work.W2JOY0AE0;
set log1 (obs=1);
new_string=compbl(translate(a_line,'',':()=+'));
keep new_string;
run;
Change that so it populates &msg_w when there is no error:
data work.W2JOY0AE0;
if done then call symput("msg_w", 'no errors');
set log1 (obs=1) end=done;
new_string=compbl(translate(a_line,'',':()=+'));
keep new_string;
run;
Of course you could use any value you would like for &msg_w, but this at least guarantees that &msg_w will exist when you have no errors. Of course if there is an error, this tweak lets the program run as it did before.
Adjust the logic as you would like from that DATA step forward.