I just found that ods graphics / reset;
broke my loop. I am still curious why this happened and if there are other potential similar pitfalls.
Objective: I want to loop over columns in SAS and provide a plot where the x variable remains constant, but the y dimension varies. I could transpose and use a by statement. I don't want to do that.
Problem:
Despite the log with options mprint ;
showing the text replacement is working properly, the outputted plots only display the final plot repeatedly rather than each individual plot. To repeat - in the log everything is incrementing properly / in the output the plot and title only show the last value of the loop.
Solution:
Delete the ods graphics / reset;
Here's a toy example:
proc sgplot data=sashelp.cars;
series x=EngineSize y=Cylinders;
scatter x=EngineSize y=Cylinders;
run;
proc sql ; select distinct NAME
into :varlist separated by ' '
from dictionary.columns
where libname='SASHELP' and memname = 'CARS' AND TYPE='num';
quit;
%let n=&sqlobs;
%MACRO PLOTYA;
%do i= 1 %to &n ;
%let currentvalue = %scan(&varlist, &i);
%put ¤tvalue;
%put &i ;
ods graphics on / width=12.5 in height=12.5in imagemap ;
title "¤tvalue &i ";
proc sgplot data=sashelp.cars;
series x=EngineSize y=¤tvalue ;
scatter x=EngineSize y=¤tvalue
;run;
ods graphics / reset;
%end;
%MEND PLOTYA;
options mprint;
%plotya ;
Thanks for your time.