I am using a stored process with streaming output on SAS9.4 M2 to generate a html page containing a chart. I want to make the chart title clickable to enable a further stored process to be run and it's resulting html rendered. To do this I have used an annotation dataset to add a link to the output of proc sgplot and positioned it at the tope where the chart title might normally be drawn. The problem I have is that every time the link is clicked the results open in a new tab, whereas I want them to replace the page in my existing tab. It seems to me that proc sgplot is adding target=_Blank to the link its generating and I want to use target=_self, is there a way to control this that I've missed?
The stored process looks like so
*processbody;
%symdel _program;
%macro mplot_chart(lprefix=);
/*This chart annotation functions as a clickable link*/
data &lprefix._annotation;
length function $ 8 url $ 255 anchor $ 5;
function="text";
label="&lprefix Chart Title";
url=cats("&_THISSESSION",'&_PROGRAM','=%2FMyMetadatafolder%2Fshowdetails&inprefix=',
"&lprefix");
textstyleelement="GraphTitleText";
textcolor="blue";
width=100;
anchor="top";
y1=100;
drawspace="GraphPercent";
output;
run;
/*Create the plot*/
proc sgplot data=save.&lprefix._plotdata
sganno=&lprefix._annotation pad=(top=25px);
series x=utcdatetime y=var1;
series x=utcdatetime y=var2 / lineattrs=(color=red);
run;
%mend mplot_chart;
ods graphics on / imagemap=on;
ods graphics / width=3.5in height=2.5in;
ods layout gridded columns=4 advance=table;
title;
%mplot_chart(lprefix=Location1);
%mplot_chart(lprefix=Location2);
title;
ods layout end;
ods graphics / reset;
/*ods html text="</div>";*/
%stpend;
This is an ODS Graphics issue, not a stored process issue. You can reproduce the problem outside of a stored process by submitting this code:
The image map created looks like this:
data work.sgplot_anno;
function = 'text';
label = 'Chart Title';
url = 'https://www.sas.com';
textstyleelement = 'GraphTitleText';
textcolor = 'blue';
width = 100;
anchor = 'top';
y1 = 100;
drawspace = 'GraphPercent';
run;
ods graphics on / imagemap=on drilltarget='_self';
ods graphics / width=3.5in height=2.5in;
title;
ods _all_ close;
ods html path='C:\temp' file='temp.htm' style=HTMLBlue;
proc sgplot data=sashelp.class sganno=work.sgplot_anno pad=(top=25px);
vbar age;
run; quit;
ods html close;
<Area shape="poly" href="https://www.sas.com" target="_BLANK" coords="135.5,0.0,200.5,0.0,200.5,19.40625,135.5,19.40625,135.5,0.0,135.5,0.0"/>
The solution is to add the DRILLTARGET option to your ODS GRAPHICS statement:
ods graphics on / imagemap=on drilltarget='_self';
The image map created now looks like this:
<Area shape="poly" href="https://www.sas.com" target="_self" coords="135.5,0.0,200.5,0.0,200.5,19.40625,135.5,19.40625,135.5,0.0,135.5,0.0"/>
Vince DelGobbo
SAS R&D
This is an ODS Graphics issue, not a stored process issue. You can reproduce the problem outside of a stored process by submitting this code:
The image map created looks like this:
data work.sgplot_anno;
function = 'text';
label = 'Chart Title';
url = 'https://www.sas.com';
textstyleelement = 'GraphTitleText';
textcolor = 'blue';
width = 100;
anchor = 'top';
y1 = 100;
drawspace = 'GraphPercent';
run;
ods graphics on / imagemap=on drilltarget='_self';
ods graphics / width=3.5in height=2.5in;
title;
ods _all_ close;
ods html path='C:\temp' file='temp.htm' style=HTMLBlue;
proc sgplot data=sashelp.class sganno=work.sgplot_anno pad=(top=25px);
vbar age;
run; quit;
ods html close;
<Area shape="poly" href="https://www.sas.com" target="_BLANK" coords="135.5,0.0,200.5,0.0,200.5,19.40625,135.5,19.40625,135.5,0.0,135.5,0.0"/>
The solution is to add the DRILLTARGET option to your ODS GRAPHICS statement:
ods graphics on / imagemap=on drilltarget='_self';
The image map created now looks like this:
<Area shape="poly" href="https://www.sas.com" target="_self" coords="135.5,0.0,200.5,0.0,200.5,19.40625,135.5,19.40625,135.5,0.0,135.5,0.0"/>
Vince DelGobbo
SAS R&D
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.