you can either: 1. Use a leading zeros format or leading spaces (replaces the 0 with space): data test;
/*create two value*/
c1=104;
c2=2;
/*add leading zeros*/
z1=c1;
z2=c2;
put1=put(c1,z8.);
put2=put(c2,z8.);
/*add leadin spaces*/
string1=tranwrd(put(c1,z8.),'0',' ');
string2=tranwrd(put(c2,z8.),'0',' ');
format z1 z8. z2 z8. ;
put _ALL_;
run; Log c1=104 c2=2 z1=00000104 z2=00000002 put1=00000104 put2=00000002 string1=1 4 string2=2 _ERROR_=0 _N_=1 Output: if you want this field to be character with leading spaces instead of 0 2. use the alignment / justify option in proc print; please refer to this post.
... View more