Setting the HTML title tag in SAS ODS (the right way)

January 5, 2010

(This article was first published on Heuristic Andrew, and kindly contributed to R-bloggers)

In our department and various places on the Intertubes, SAS programmers set the HTML title tag (which sets the title in web browsers and on search engines) in ODS using the headtext option:

ods html
 headtext="My great report" /* wrong! */

This may work in some situations, but it’s ugly and wrong. To see why, view the raw HTML:

My great report

SAS Output

Each HTML page should only have one TITLE tag, but this method creates an additional tag instead of replacing the first. Some web browsers and spiders may use the second tag instead of the first, and the document won’t validate as HTML (not that you can fix SAS’s HTML completely). If your document is only on an intranet think of personal and corporate document indexing systems (Google Search Appliance, Google Desktop Search, Windows Search, etc.), and even if it works now, you want to future-proof your HTML reports when (not if) new technology comes in to the mix.

I discovered the correct way thanks to Chevell Parker:

ods html
 file="foo.html" (title="My great report"); /* correct way to set the HTML title tag */

This was tested on SAS 9.1.3 SP4 on Windows XP SP3.

To leave a comment for the author, please follow the link and comment on their blog: Heuristic Andrew. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)