BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SR_FR
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

8 REPLIES 8
Ksharp
Super User

Are you coming from Germany ?

Check function HTMLDECODE () and HTMLENCODE () .

Xia Keshan

SR_FR
Obsidian | Level 7

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...

Ksharp
Super User

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

SR_FR
Obsidian | Level 7

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! 

Cynthia_sas
SAS Super FREQ

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
SR_FR
Obsidian | Level 7

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

jakarman
Barite | Level 11

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 --<-----
jakarman
Barite | Level 11

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 --<-----

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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