I dont understand what is going on in my SAS code. The code behaves as expected, but only during the first time it compiles, i.e. the table called \'SummaryTable\' shows the
I think you're running into issue's with how call execute is working and when the macro variables are resolving. My reasoning for that is if you call the macro individually via %ModelsSummary(..) the error does not occur. I don't know why it's occurring and hopefully someone has a better response for you. A workaround is to use unique macro variables, i.e. add &count at the end of MyLogLik macro variable.
%macro ModelsSummary(Count,Var,Param);
proc sql;
select _LNLIKE_ into :MyLogLik&count from parameters&Count;
insert into SummaryTable (ModelNumber,ModelVariables,NumParameters, LogLik) values (&Count,"&Var",&Param, &&MyLogLik&count);
drop table parameters&Count;
quit;
%mend;