convert HTML to PDF

Occasional Contributor
Posts: 16

convert HTML to PDF

May i know if we Can read HTML file in sas and convert into PDF ? 


Currerntly Iam using third party tools like and so on..


I just want read final output.html file and conver into pdf



Super User
Posts: 23,776

Re: convert HTML to PDF

Is the output.html file from SAS? Can you provide some more details?


There's no direct method, but if it's SAS output that can also be redirected to a PDF file. You can also use third party tools directly from SAS using the X/SYSEXEC command to call them.

Occasional Contributor
Posts: 16

Re: convert HTML to PDF

yes , the HTML output is from SAS


Basically I didn't wrote any html code inside the sas code , First we created the html_template and then we passed macro variable to the html.
1) SAS code : 
data send_to_html;
set input_table;
/* define the code to run for each observation */
/*  /sas/config/ma/Lev1/SASMA/test*/
code = 'filename letter "location/filename.html" ' 
||'lrecl=32767 ; '
||'proc stream outfile=letter mod quoting=both;  '
||'begin '
||'&streamdelim; %include test(html_template.html); '
/*  ||'filename letter clear;'*/
/* run the code */
rc = dosubl(code);


2) html template example : shorrex_template.html
<!DOCTYPE html>
<h1>&first_name.</h1>  /*macro variable from sas */
Super User
Posts: 13,583

Re: convert HTML to PDF

The basic SAS output to PDF is ODS. You would place procedures that generate output between an ODS PDF destination statement and an ODS PDF Close statement.


ods pdf file="C:\path\myfile.pdf";


proc print data=sashelp.class;



ods pdf close;


Would create the PDF file myfile.pdf in the folder C:\path and have the results of the proc print.


If you are writing raw html then this approach likely won't help.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation