The SAS Output Delivery System and reporting techniques

HTML5 and HTML tags in my title... possible ?

Accepted Solution Solved
Reply
Contributor
Posts: 43
Accepted Solution

HTML5 and HTML tags in my title... possible ?

Hi to all

I'd like to produce a HTML5 document and want to use HTML tags the same way I did with ODS HTML - I'm having a problem...

see this example :

ods html5 path=odsout body="test.html";

Title "<img src='http://www.v3.co.uk/IMG/479/168479/sas-logo-540x334.jpg'</img>";

proc print data=sashelp.class(obs=2);

run;

ods html5 close;

the result is here :

Sortie SAS

when looking at the source code, it seems that < and > are replaced, with HTML5 by &lt; and &gt;, single quotes are replaced by &apos;


Not very easy in that case to see the tags I'd like to use...


Do we have ways to produce an HTML5 document with basic (old school) HTML tags ?


thanks in advance!


best regards


Sébastien


Accepted Solutions
Solution
‎01-07-2015 09:55 AM
Super User
Posts: 9,867

Re: HTML5 and HTML tags in my title... possible ?

Here is a workaround (using University Edition) . If you like it . open /folders/myfolders/title.html

filename want '/folders/myfolders/title.html' ;

filename x temp;

ods html5 file=x;

Title "<img src='http://www.v3.co.uk/IMG/479/168479/sas-logo-540x334.jpg'</img>";

proc print data=sashelp.class(obs=2);

run;

ods html5 close;

data _null_;

infile x lrecl=32767 length=len;

file want lrecl=32767;

input x $varying32676. len;

x=htmldecode(x);

put x $varying32676. len ;

run;

Xia Keshan

View solution in original post


All Replies
Super User
Posts: 9,867

Re: HTML5 and HTML tags in my title... possible ?

Are you coming from Germany ?

Check function HTMLDECODE () and HTMLENCODE () .

Xia Keshan

Contributor
Posts: 43

Re: HTML5 and HTML tags in my title... possible ?

no, from France ;-)

This explains why I'm not very clear in my explanations!

the functions you indicated won't be useful in my situation since my problem is not a data step problem.

html tags in my TITLE statement are not considered as tags with ODS HTML5 because ODS HTML5 is encoding special characters (<>') - ODS HTML didn't do that.

In fact, I need to tell to ODS HTML5 not to encode. My problem is very similar to a quoting problem...

Solution
‎01-07-2015 09:55 AM
Super User
Posts: 9,867

Re: HTML5 and HTML tags in my title... possible ?

Here is a workaround (using University Edition) . If you like it . open /folders/myfolders/title.html

filename want '/folders/myfolders/title.html' ;

filename x temp;

ods html5 file=x;

Title "<img src='http://www.v3.co.uk/IMG/479/168479/sas-logo-540x334.jpg'</img>";

proc print data=sashelp.class(obs=2);

run;

ods html5 close;

data _null_;

infile x lrecl=32767 length=len;

file want lrecl=32767;

input x $varying32676. len;

x=htmldecode(x);

put x $varying32676. len ;

run;

Xia Keshan

Contributor
Posts: 43

Re: HTML5 and HTML tags in my title... possible ?

ok!

I get the idea ;-)

but I'm having 192 files to convert this way..

and I think that the HTMLDECODE function will decode 'too much'... In France, we use lots of special characters and I'm quite sure it will create a mess in my webpages... for instance for that kind of title :

title "<h3>say 'yes' if you agree</h3>"

I certainly try to use the TRANSWRD function instead to control the replacement...

thanks for your help! 

SAS Super FREQ
Posts: 8,819

Re: HTML5 and HTML tags in my title... possible ?

Hi,

  The code below (turning off the encoding) worked for me in SAS 9.4. As you can see, the style template caused the < and > to go through to the HTML file unchanged.

Cynthia

ods _all_ close;

ods path work.tmp(update) sasuser.templat(update) sashelp.tmplmst(read);

proc template;

define style styles.oktitle;

parent=styles.htmlblue;

class systemtitle from systemtitle/

  protectspecialchars=off;

end;

run;

  

ods html5 file='c:\temp\spectitle.html' style=styles.oktitle;

proc print data=sashelp.class;

title '<img src="http://www.v3.co.uk/IMG/479/168479/sas-logo-540x334.jpg" </img>';

run;

ods html5 close;


using_style_template_change.png
Contributor
Posts: 43

Re: HTML5 and HTML tags in my title... possible ?

Hi Cynthia!

This is exactly what I was looking for!

many thanks!

I adapted your PROC TEMPLATE because my footnotes and values contains tags... (tags everywhere...)

proc template;

   define style styles.modif;

   parent=styles.htmlblue;

   class TitlesAndFooters from TitlesAndFooters /

      protectspecialchars=off;

   class data from data /

      protectspecialchars=off;

   end;

run;

best regards

Sébastien

Valued Guide
Posts: 3,208

Re: HTML5 and HTML tags in my title... possible ?

Most Html is moving to Unicode standard.  That is different to most most SAS sessions still using latin1 types.

>> First remark: I would avoid being dependent on old latin1 approaches.

>> Second remark: them image tagset does not have a closing tag.  HTML Images . You html coding is not correct.

As the whole concept of template and styles by SAS is hiding the technical solution of coding from  SAS coding it should be possible be using just that.

>> Third remark: had coding bypassing this approach can bring you at some time into troubles.

Yes setting the protection off for this one will help you in the short term. Adjusting all styles in all the installation you have is more troublesome. 

Is it possible with ODS? Yes:

Using the following will work also. The only remark is the odsescape function is checking for the file on the local system.

As is does not exist local it is generating an error, but having the correct results.

I am looking for a way to define own odsescape fucntions but cannot find that.  

A function for embedding an image (no errors on external links) would be a good enhancement.

SAS(R) 9.4 Output Delivery System: Procedures Guide (template procedure: Createing s Style Image)  attributes with the style, mentioning post/pre image.   

ods escapechar="^" ;

ods trace on  dom ;

Filename odsout "%sysfunc(pathname(test))" ;

ods html5 path=odsout body='test.html'  ;

Title " ^{style[preimage='http://www.v3.co.uk/IMG/479/168479/sas-logo-540x334.jpg']} prim ";

proc print data=sashelp.class(obs=2);

run;

ods trace off;

ods html5 close;

For fun this one is nice to see what is possible with css/html this way using a sas program. http://support.sas.com/resources/papers/proceedings13/015-2013.pdf 

---->-- ja karman --<-----
Valued Guide
Posts: 3,208

Re: HTML5 and HTML tags in my title... possible ?

osdascapechar function, got it : http://support.sas.com/resources/papers/proceedings09/222-2009.pdf not fully complete

<cite>

  If that works, what else can we do? Lots! How about an IMAGE function?

define event inline_image;
putq "<img" "src=" value ">";
end;
title2 "Example ^{style of ^{line} an image {inline_image
Droplet.jpg} ^{newline} ^{line}}"
<image......>

</cite> (Eric Gebhart, SAS Institute Inc., Cary, NC)

Only the connection of that definition to an odsescapechar function still missing. 


---->-- ja karman --<-----
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1031 views
  • 0 likes
  • 4 in conversation