The SAS Output Delivery System and reporting techniques

ODS PDF Proc Report & HTML Data

Occasional Contributor
Posts: 19

ODS PDF Proc Report & HTML Data

Hello -


I have a dataset that contains text wrapped in HTML coding in one of the columns.  I'd like to run an ODS PDF Proc Report on top of this data, and have the text render in the manner the HTML code would have it render.  Is that possible? 


An example dataset woudl be below.  In this example, I'd like the "text" column to show up in the PDF and maintain any bold/underline/bulleted lists as the HTML coding would dictate.


Any thoughts would be helpful!!


data work.html_text;

infile datalines delimiter='~';

format id 5.0 savedby text $5000.;

input id savedby $ text $;


1~Smith~<!DOCTYPE html><html><head></head><body><p>This is Paragraph One</p><p>This is paragraph 2</p></body></html>

2~Johnson~<!DOCTYPE html><html><head></head><body><p>This is HTML text</p></body></html>





Grand Advisor
Posts: 16,367

Re: ODS PDF Proc Report & HTML Data

I doubt it. PDF won't understand the HTML and SAS doesn't have an automatic way to interpret it.

You could try using ODS HTML and then printing to PDF but I'm not sure how that file would turn out either. Or use ODS HTML with a PDF extension....all of these are guesses though.
Posts: 8,645

Re: ODS PDF Proc Report & HTML Data

I agree with Reeza that this seems unlikely.

You might investigate whether there is an Adobe product that will open an HTML file, render it and then save as PDF. The issue I think you're going to run into is that SAS does not "own" HTML -- so internally, there is nothing in SAS that knows how the HTML would be rendered by a browser, so that SAS could "translate" that look and feel into PDF. According to the rules of HTML, the file you have violates the rule that you have only 1 <!DOCTYPE> tag in the document, only 1 <html> tag, only 1 <body> tag -- so I am not actually sure that your HTML file would be rendered in a browser. Also, your DOCTYPE doesn't look entirely correct. And it looks like your <head> doesn't have any <style>, so it is an odd file. The fact that you have an INPUT statement with ID and SAVEDBY as variables looks almost like you are trying to save an entire <HTML> document for every SAVEDBY person -- and that is a bit odd to want to put into PDF because every SAVEDBY person could have different text in their paragraphs and their formatting on their HTML page might be different from SAVEDBY person to SAVEDBY person.

SAS is not a browser. The HTML tags you are sending are just text strings. So you would have to build any "intelligence" for the rendering of the HTML in your data by yourself -- that means, you have to essentially tell SAS how YOU wanted EACH and EVERY HTML tag to be sent to PDF.

PDF is not a browser. So if an Adobe product can read an HTML file and create a PDF file, then you would have to investigate whether an Adobe product could read multiple, different HTML files and create 1 PDF file from multiple HTML files (this seems possible, but I am guessing that Adobe might charge $$ for a product like this).

For the definitive answer about whether what you want to do is possible my recommendation is that you open a track with Tech Support.

Post a Question
Discussion Stats
  • 2 replies
  • 3 in conversation