I'm trying to pull in fields called Mort1, Mort2, Mort3, etc. depending on what value is in my variables, MortDuration&i. This returns text of Mort1, Mort2, etc. instead of the values: %LET i=1; %DO k=&i %TO &j; CAT(Mort,Calculated MortDuration&i) as Mortality&i, %LET i=%EVAL(&i+1); %END; If I replace the variable I want with a constant, it works: %SYSFUNC(CAT(Mort,1)) as Mortality&i, (only it always returns Mort1) And this returns an error: %SYSFUNC(CAT(Mort,Calculated MortDuration&i)) as Mortality&i, Here is my original non-macro, very ugly code that was working: ifn(Calculated MortDuration1=0,Mort0,ifn(Calculated MortDuration1=1,Mort1,ifn(Calculated MortDuration1=2,Mort2,ifn(Calculated MortDuration1=3,Mort3,ifn(Calculated MortDuration1=4,Mort4,.... etc. as Mortality1,
... View more