this is a toy example in order to help with a larger problem I have. It essentially involves using a %eval() macro when referencing a bigger macro variable name.
I have created a macro variable x_2, which uses the values of the loop, '&it', the variable is created successfully as can be seen by the final output, however I can only put it to the log without evaluating &it+1, which I will need to do when using a loop bigger than size 1.
It seems to resolve x_ first, giving a warning, before then evaluating x_2 as a whole and giving the output.
I realise this is just a problem about how to reference macros correctly, but I cannot find any examples where it uses an evaluation as part of a macro variable name.
Thanks.
%macro testing;
%DO it = 1 %TO 1;
data dataset;
s=100;
t=99;
run;
data _null_;
set dataset;
if s = 100 then do;
call symput("x_%eval(&it+1)",t);
end;
run;
%put "&x_%eval(&it+1)";
%put &x_2;
%END;
%mend testing;
%testing;
LOG OUTPUT
MLOGIC(TESTING): %PUT "&x_%eval(&it+1)"
WARNING: Apparent symbolic reference X_ not resolved.
SYMBOLGEN: Macro variable IT resolves to 1
SYMBOLGEN: Macro variable X_2 resolves to 99
" 99"
MLOGIC(TESTING): %PUT &x_2
SYMBOLGEN: Macro variable X_2 resolves to 99
99
MLOGIC(TESTING): %DO loop index variable IT is now 2; loop will not iterate again.
MLOGIC(TESTING): Ending execution.