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

The following code produces HTML wherein the specified headtext gets truncated to 256 characters.

 

Q: Does any know how to increase the allowed headtext or otherwise inject such?

 

SAS program specifying a head text of 320 characters

options lrecl=32000;  * does nothing for me regarding headtext! ;

ods html 
  path='.'
  file = 'sample.html'
  style=plateau
  headtext=
'<!--5678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567890
12345678901234567890123456789012345678901234567890123456789012345678901234567-->'
;

proc print data=sashelp.class;
run;

ods html close;

HTML output source with headtext truncated to 256 characters

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
<meta name="Generator" content="SAS Software Version 9.4, see www.sas.com">

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

From the documentation for ODS HTML ( I added some emphasis). I don't know if that a general HTML limit or SAS ODS limit.

 

HEADTEXT= 'markup-document-head'

specifies markup tags to place between the < HEAD> and < /HEAD> tags in all of the output files.

markup-document-head

specifies the markup tags to place between the < HEAD> and < /HEAD> tags.

Restriction HEADTEXT= cannot exceed 256 characters.
Requirement You must enclose markup-document-head in quotation marks.
Tips ODS cannot parse the markup that you supply. It should be well-formed markup that is correct in the context of the <HEAD> and </HEAD> tags.
Use the HEADTEXT= option to define programs (such as JavaScript) that you can use later in the file.

View solution in original post

2 REPLIES 2
ballardw
Super User

From the documentation for ODS HTML ( I added some emphasis). I don't know if that a general HTML limit or SAS ODS limit.

 

HEADTEXT= 'markup-document-head'

specifies markup tags to place between the < HEAD> and < /HEAD> tags in all of the output files.

markup-document-head

specifies the markup tags to place between the < HEAD> and < /HEAD> tags.

Restriction HEADTEXT= cannot exceed 256 characters.
Requirement You must enclose markup-document-head in quotation marks.
Tips ODS cannot parse the markup that you supply. It should be well-formed markup that is correct in the context of the <HEAD> and </HEAD> tags.
Use the HEADTEXT= option to define programs (such as JavaScript) that you can use later in the file.
RichardDeVen
Barite | Level 11

The > 256 character was for including a number of external javascript libraries.

 

I was able to get around the issue by placing some of the <script> tags at the bottom of the html

 

Example:

filename htmlout "great-page.html";

ods html body=htmlout (NO_BOTTOM_MATTER) style=plateau
  headtext='<link rel="stylesheet" href="https://cdn.datatables.net/1.11.0/css/jquery.dataTables.min.css">'
;

* tagattr is IMPORTANT;
proc print data=sashelp.class  style(table)=[tagattr='id="MyTable1"'];
run;

ods html close;

* stuff that would not fit in html HEADTEXT limit of 256 characters; data _null_; file htmlout MOD; put '<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>' / '<script src="https://cdn.datatables.net/1.11.0/js/jquery.dataTables.min.js"></script>' / '<script>' / '$(document).ready(function(){' / ' debugger;' / ' $("#MyTable1").DataTable({paging: false});' / '})' / '</script>' ; put '</body>' ; run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 524 views
  • 1 like
  • 2 in conversation