When your macro variable is resolved, this code is the result:
data a;
ax=put(007 , $4);
run;
007 is a numeric literal with the value 7 (numbers do not have leading zeroes, leading zeroes can only be created by numeric formats).
But:
Maxim 3: Read the Log:
72
73 %let i = 007;
74
75 data a;
76 ax=put(&i. , $4);
_
85
76
ERROR 85-322: Expecting a format name.
ERROR 76-322: Syntax error, statement will be ignored.
77 run;
Your incorrect use of a format (missing dot) causes a syntax ERROR.
After correction, we get this:
73 %let i = 007;
74
75 data a;
76 ax=put(&i. , $4.);
WARNING: Variable 007 has already been defined as numeric.
77 run;
which is a consequence of your use of a character format for a numeric value.
So we need to use a proper numeric format that displays leading zeroes, and with the correct number of digits:
%let i = 007;
data a;
ax=put(&i. , z3.);
run;
But since you want a character value, this is accomplished in a much much simpler way:
%let i = 007;
data a;
ax = "&i.";
run;
by directly creating a character value from your macro variable.