BookmarkSubscribeRSS Feed
grodman
Obsidian | Level 7

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

datalines;

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>

;

run;

 

 

2 REPLIES 2
Reeza
Super User
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.
Cynthia_sas
SAS Super FREQ
Hi:
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.

cynthia

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1393 views
  • 0 likes
  • 3 in conversation