Here is some potential code that you can use. I created a macro with two arguments, you just need to add the graph, i.e. the parameter and also the equation.
data stocks;
set sashelp.stocks(in=a) sashelp.stocks(in=b);
if a then do;
graph = "Graph 1";
end;
if b then do;
close = close + 100 + (close *2);
graph = "Graph 2";
end;
run;
%macro legend(equation=, graph=);
title1 #byval1;
proc sgplot data=stocks(where=(date >= "01jan2000"d and stock = "IBM"));
by graph;
where graph = "&graph";
series x=date y=close / name = "leg" legendlabel=" ";
keylegend "leg" / title = "&equation" type=line;
run;
%mend;
%legend(equation=%str(Y=X), graph=%str(Graph 1));
%legend(equation=%str(Y=100 + 2X), graph=%str(Graph 2));
... View more