I need to have a variable with size 2 and leading zeros, such as 01, 02, 10, 11..., to I use in a macro. The macro executa1 works, but shows the values 1,2,10,11 .... (without the zero). So I tried to use the z2. format, like macro executa2.
But unfortunately, it doesn't work.
%LET vdia = 01;
%LET vano = 2019;
%MACRO executa1;
%DO i=1 %TO 12 %BY 1;
%LET vmes = &i;
%PUT &vmes;
%END;
%MEND;
%MACRO executa2;
%DO i=1 %TO 12 %BY 1;
%LET vmes = %PUT(&i, z2.);
%PUT &vmes;
%END;
%MEND;
%executa1
%executa2
Log with error (executa2):
39 %LET vmes = %PUT(&i, z2.);
ERROR: Macro keyword PUT appears as text.
ERROR: A dummy macro will be compiled.
I also tried some combinations of %eval() and %sysfunc(), but to no avail.
Would anyone know any tips to achieve the expected result?
%PUT
is a macro statement. You can not assign a variable a statement. You assign a variable a value, a resolvable expression, macro resolution or macro invocation that may or may not emit source code as the RHS. – Richard