skijunkie
skijunkie

Reputation: 151

Using "ods html text=" to inject html into an output document for a batch SAS program

I am currently trying to setup an automated SAS report. I have written the following test batch program for the automation piece that will be scheduled in Windows Task Scheduler:

"C:\SAS Location\sas.exe" -sysin "C:\SAS program location\test_report.sas" -LOG "C:\Log    location\test_report.log" -PRINT "C:\Output Location\test_report.lst"

and the following basic report beginning as follows:

%let date = %sysfunc(date(),worddate.);
ods graphics on;
title;

ods html path='C:/folder for HTML file'
     gpath='C:/folder for images'  
     body="dental_screen_report_&sysdate..htm"
     headtext="<title>Dental Screening Report &date</title>"
     style=htmlblue;

ods html text="
<table style='width:100%'>
<tr style='text-align:center'>
    <td><a    href='C:/Location of PDF version of report/dental_screen_report_&sysdate..pdf'>Download PDF</a></td>
</tr>
</table>
</br>
";

*proc template code is placed in here to generate report.
ods html close;

When I run the code directly in SAS the html code I inject with a link to the PDF works fine, but when run with the batch program, it looks like the html is not encoded correctly (shown below). The rest of the report is fine, it is just the PDF link that no longer works.

<div class="l usertext">    &lt;table style=&#39;width:100%&#39;&gt;    &lt;tr style=&#39;text-align:center&#39;&gt;        &lt;td&gt;&lt;a href=&#39;C:/Users/GarrettWeaver/desktop/urgent/pdf/dental_screen_report_26MAR14.pdf&#39;&gt;Download PDF&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt; &lt;/table&gt;  &lt;/br&gt;</div>

I am not sure how to go about making this work correctly through the batch program. Would it be better to just add the link outside of SAS, rather than inserting within the SAS program?

Appreciate any suggestions.

Upvotes: 1

Views: 2216

Answers (1)

skijunkie
skijunkie

Reputation: 151

Figured it out.

For this to work in a batch file, there can be no spaces, return characters, tabs, etc. Not sure why this is the case, if any one has a more detailed reason for why this is the case when SAS is run in batch mode, do let me know. Thanks.

ods html text="<table style='width:100%'><tr style='text-align:center'><td><a href='C:/Location of PDF version of report/dental_screen_report_&sysdate..pdf'>DownloadPDF</a></td></tr></table></br>";

Upvotes: 1

Related Questions