I'm in the final stages of a data standardisation effort here at work.
There are two data columns, each being of type CHAR. They mostly contain numeric IDs, but some contain letters in the middle of the number strings as well. What I wish to do is ensure that all of the variables contain 10 characters, and if they contain less than that, pad out the left-hand-side with 0s.
If the variables were guaranteed to be wholly numeric I would simply convert to a number and then use PUT with the Zw. format, but that isn't applicable here.
Here's a solution in macro format, to stop this topic being a waste of space...
&variable. = REPEAT("0",&varlen.-length(&variable.)) || &variable.;