The SAS Output Delivery System and reporting techniques

Links in HTML created by ODS and sent by Filename EMAIL

Reply
Super Contributor
Posts: 260

Links in HTML created by ODS and sent by Filename EMAIL

Hello all.

I was showing the wonders of piping ODS HTML into a FILENAME EMAIL during a training session a few days ago, producing a quite long HTML file including outputs from various procedures (mostly Print). Via ODS HTML TEXT, I added anchors and internal links to navigate into the page, from a table (which had a Contents Table role).
Everything was perfect until someone tried to view the mail on his Web Outlook page, and to use the links : each and every link has been added a TARGET="_BLANK" option in the HTML code and opened a new window each time being clicked on.
I've tried to force the TARGET="_SELF" option in my ODS HTML TEXT instructions : no success.

Where do these options come from ? Is it OS-related (mails generated on a Unix platform via EG) ? Any idea to circumvent the problem ?

Thanks in advance.
Olivier
SAS Super FREQ
Posts: 8,868

Re: Links in HTML created by ODS and sent by Filename EMAIL

Olivier:
When I use this syntax (I ran the code on Windows 9.1.3 (without doing any piping or emailing) because I wanted to see what BASE SAS was doing in a simple situation.):
[pre]
ods html path='c:\temp' (url=none)
file='bod.html'
contents='toc.html'
frame='frame.html' style=sasweb;
proc print data=sashelp.class;
title link='http://www.amazon.com' 'Go to Amazon';
var name / style(data)={url='http://www.sas.com'};
var age height;
run;
[/pre]
I find a target="body" in the contents= (toc.html) file, NOT a target="_blank". Also, my internal links (what has been placed in the body (bod.html) file) does NOT have a TARGET= at all, so when the link (in the PROC PRINT is clicked), it populates in the same window. Or when the link from the title is clicked, it also fills up the body area of the frame because there is NO target= being created.
This is what's in the CONTENTS= file: (using VIEW-->SOURCE in browser to see underlying HTML):
[pre]
<a href="bod.html#IDX" target="body">Data Set SASHELP.CLASS</a>
[/pre]
and THIS is what's in the FILE= file:
[pre]
<td class="c SystemTitle"><a href="http://www.amazon.com">Go to Amazon</a>
and
<td class="l Data"><a href="http://www.sas.com">Alfred</a>
[/pre]

I am at a loss to figure out how target="body" got changed to target="_blank" -- unless there was some tagset template change???? Or, how target=_blank got in your output at all without a tagset change. Or maybe you were not using the HTML tagset as it was delivered by SAS?

I think this is a good question for Tech Support.

cynthia
Super Contributor
Posts: 260

Re: Links in HTML created by ODS and sent by Filename EMAIL

Posted in reply to Cynthia_sas
Hi Cynthia.

In fact, I've summarized my problem a little too much. I'm not using any built-in contents, I make it up by myself.
Here is some mimic of my original program (sorry, the HTML commands got interpreted) :


ODS HTML FILE="sample.htm" ;
PROC FORMAT ;
VALUE $links
"F" = 'F'
"M" = 'M'
;
RUN ;
ODS HTML TEXT='' ;
PROC FREQ DATA = sashelp.class ;
TABLE sex ;
FORMAT sex $links. ;
RUN ;
ODS HTML TEXT='
' ;
TITLE "Girls" ;
PROC PRINT DATA = sashelp.class NOOBS ;
WHERE sex = "F" ;
RUN ;
ODS HTML TEXT='
Back to the top of the page' ;
ODS HTML TEXT='' ;
TITLE "Boys" ;
PROC PRINT DATA = sashelp.class NOOBS ;
WHERE sex = "M" ;
RUN ;
TITLE ;
ODS HTML...
Back to the top of the page' ;
ODS HTML CLOSE ;

It works out just fine.
But I ran into problems when I changed the FILE option of my ODS HTML statement for a filename...

FILENAME outbox EMAIL TO="someone@home.fr" SUBJECT="ODS test" ;
ODS HTML FILE = outbox ;

Running that code in Enterprise Guide 4 on Unix sent mails where the internal links (to #girls, #boys, #top) were added a TARGET=_BLANK attribute (weird, isn't it ?).
Except for magic, what could explain that ? I will be working in the same company next Monday, so I can run tests if you have some hints.

Thanks in advance.
Olivier

SAS Super FREQ
Posts: 8,868

Re: Links in HTML created by ODS and sent by Filename EMAIL

Olivier...if you use square brackets [ ] around the string pre, then your program will not wrap oddly. Also at the end of your code put a /pre inside square brackets:
[ pre ] but with no spaces.

Also for your ODS TEXT=, you could try typing into the forum window as & + lt; and & + gt; for the < and > around HTML tags. (That's ampersand lt; without any spaces or ampersand gt; without any spaces)

I will test out ODS TEXT= and see what happens in either case.

cynthia
SAS Super FREQ
Posts: 8,868

Re: Links in HTML created by ODS and sent by Filename EMAIL

Posted in reply to Cynthia_sas
Olivier:
I tested the following code (which is a bit different from yours):
[pre]
** create a file with internal named links using the #IDX1 and #IDX2 convention;
title; footnote;
proc format;
value $gndlnk 'F' = '#IDX1'
'M' = '#IDX2';
run;

** create an HTML file;
ods html file='c:\temp\olivier.html' style=sasweb;
proc report data=sashelp.class nowd;
Title 'This report is #IDX';
column sex n pctn;
define sex /group
style(column)={url=$gndlnk.};
define n / 'Count';
define pctn / 'Percent' f=percent7.1;
run;

ods html text='<center><a href="http://www.sas.com">Go to SAS</a></center>';

proc print data=sashelp.class;
where sex = 'F';
title 'Girls (#IDX1)';
title2 link="#IDX2" 'Go to Boys Report' ;
var name age height;
footnote link='#IDX' 'Back to Top';
run;
ods html text=' ';

proc print data=sashelp.class;
where sex = 'M';
title 'Boys (#IDX2)';
title2 link='#IDX1' 'Go to Girls Report';
var name age height;
footnote link='#IDX' 'Back to Top';
run;

ods html close;


** note that I sent my mail as an attachment;
filename doemail email
to=('diff_person@comcast.net')
from='me@sas.com'
cc=('me@sas.com')
subject='Testing attach of ODS HTML output'
attach='c:\temp\olivier.html';
data _null_;
file doemail;
put 'This is a test email with attachment. I will send the';
put 'program by separate mail to you.';
run;
[/pre]

Note that in order to run the above test, you would have to change the TO, FROM and CC addresses in the code above. I ALWAYS send my output as an attachment because I like to send an explanatory message about what it is that I am sending. And besides, having a file allowed me to make sure that the links were built correctly at the SAS end before I did the email. Then, I also could compare the file that I received with the file I created to make sure that nothing changed.

When I tested my code, I did NOT get TARGET="_BLANK" inserted when I emailed as an attachment. Not in my internal LINKS and NOT in the LINK that I hardcoded with ODS HTML TEXT=, either. I used PROC REPORT instead of PROC FREQ, because PROC REPORT allows me to set a URL with a format without needing to code an entire syntactically correct HTML <A> tag.

If you are still having problems and you really believe it is SAS and ODS that are inserting TARGET="_BLANK" somehow into your email PIPEd file, then your best bet is to contact Tech Support. However, I suggest you try the above program first and see if you get the same results as I did.

cynthia
Ask a Question
Discussion stats
  • 4 replies
  • 329 views
  • 0 likes
  • 2 in conversation