For me macro code is harder to read than normal base SAS code so my personal approach is to only use macro coding if there is a real gain in doing so. Also: You're still using "substr()" instead of "subpad()" so the initial issue would remain.
I am not saying that my approach is the best one, but this is the one for the people who don't like complex do loops or Perl regular expressions.
And while writing the code,i thought of use Subpad function,but my fingers automatically typed Substr function as i am frequent user of that function ,infact i haven't recognised that typo..Thanks for correcting me.