The SAS Output Delivery System and reporting techniques

title link target=_blank

Reply
Regular Contributor
Posts: 196

title link target=_blank

How do I modify this code so that the link opens in a new window?
I know that it involves target=_blank, but I'm not sure what the syntax is.

title1 link="www.sas.com" SAS;

Thank you.
SAS Super FREQ
Posts: 8,743

Re: title link target=_blank

Hi:
You need to change the HREFTARGET style attribute, as described in this note:
http://support.sas.com/kb/23/437.html

The HREFTARGET attribute can be specified in a style template OR, in a TITLE statement, if you change the form of the link to be entirely specified with an ODS ESCAPECHAR style attribute override, you can do this:
[pre]
ods html file='c:\temp\uselink.html' style=sasweb;

ods escapechar='^';
title1 "^S={url='http://www.sas.com' hreftarget='_blank'} SAS";

proc print data=sashelp.class(obs=3);
run;

ods html close;
[/pre]

The only real difference is that instead of LINK= (which is a TITLE option), you are using URL= (which is a style attribute), but because you specify URL= in the ^S override, you can also specify HREFTARGET= within the same override.

ODS ESCAPECHAR must be set to the same character in the declaration statement as the character you use in the style override in the TITLE statement. For example, if you had:
[pre]
ODS ESCAPECHAR='~';

...then your TITLE statement would need to have the tilde (~) used:
title1 "~S={url='http://www.sas.com' hreftarget='_blank'} SAS";
[/pre]

This worked for me in SAS 9.2. For more information about ODS ESCAPECHAR capability, look in the ODS DOCUMENTATION or refer to these papers:
http://www2.sas.com/proceedings/forum2007/099-2007.pdf
http://www.nesug.org/Proceedings/nesug07/cc/cc18.pdf
http://www.nesug.org/proceedings/nesug08/np/np10.pdf
http://www2.sas.com/proceedings/sugi31/227-31.pdf
http://support.sas.com/resources/papers/sgf2008/odspdf.pdf

cynthia
Regular Contributor
Posts: 196

Re: title link target=_blank

This works:
ods escapechar='^';title1 "^S={url='http://www.sas.com' hreftarget='_blank'} SAS";

Which device is good to use with this (other than activex)?
I'm using ods tagsets.tableeditor and my output is html.
Thank you.
SAS Super FREQ
Posts: 8,743

Re: title link target=_blank

Hi:
I'm not sure what you mean by "device". This title statement should work for any ODS output in a destination which supports styles and in a viewer that supports hyperlinks. So, for example, ODS HTML, ODS RTF and ODS PDF will all support the use of a URL or hyperlink in the title. However, ODS RTF, when opened in Microsoft Word will require that you CTRL+click the hyperlink to follow the link.

Generally, folks who use a "device" are using SAS/GRAPH device-based procedures (such as GCHART and GPLOT). The issue here is that ODS ESCAPECHAR is not used in SAS/GRAPH output. So, if the title you show is meant to go on a graph and the SAS/GRAPH device is in control of the title, then you can't use ODS ESCAPECHAR for that title.

Several ODS destinations (ODS HTML, ODS RTF) have the NOGTITLE, NOGFOOTNOTE options, which allow ODS to control the title (instead of SAS/GRAPH). If you use these options, then you could use ODS ESCAPECHAR in your SAS title and footnote. TAGSETS.TABLEEDITOR is an HTML-based destination. However, I do not know whether NOGTITLE and NOGFOOTNOTE are allowable options for TAGSETS.TABLEEDITOR when you use SAS/GRAPH. You would have to check the documentation or work with Tech Support on this question.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 539 views
  • 0 likes
  • 2 in conversation