11-20-2012 01:33 PM
[Env: SAS 9.3, Win Xp]
For a web application, I want to generate an HTML file containing a series of <table>s, one for each month of the year,
where I produce the HTML file entirely in a DATA _NULL_ step, and don't want SAS to add any additional markup
(largely because it is easier for me this way, than to figure out all the details of ODS markup).
As well, I'm combining information from two different sources, so have to use a DATA _NULL_ approach for custom output,
and have also encountered problems due to character encoding issues (HTML entities vs. latin1).
In the hope that someone can help, I'm attaching several files:
- aevents.sas: Generate the output calendar.html
- calendar.html: Current output
- author-aevents.csv (input file, HTML encoded)
- events.csv (input file, latin1 encoded)
In the attached SAS file, I've gotten my best results so far using the ODS CHTML destination, starting with
ods chtml body="c:\documents\milestone\databases\calendar.html"
title='Milestones Calendar Events')
but the results are still far from desired, because SAS still inserts extraneous material before my code results,
and inserts <pre> ... </pre> tags around various sections of my output.
<a name="IDX"><h1>Milestones Calendar Events</h1>
<table columns="1" cellpadding="2" border="1">
In addition, one of my data sources have accented characters encoded in HTML entities, e.g., é while the other has them
encoded in latin1, e.g., é. In the output HTML file, with HTML entities, I get entries like this:
|<td class="day">10 </td>|
|<td><img src='tombstone.png' width=24> </td>|
|<td>died: Émile Cheysson 1910 (Leysin, Switzerland) </td>|
However, with latin1 characters, I get entries where all HTML characters are escaped, so the <tr> ... </tr> doesn't
appear as a table row. I don't know how to convert latin1 character to HTML entities, either in the PROC IMPORT
step or afterwards to avoid this. I'm even willing to pre-process the events.csv file if necessary.
|<td class="day">14 </td>|
|<td><img src='calendar.png' width=24> </td>|
|<td>event: Pierre Simon Laplace 1814|
|Laplace presents Essai philosophique sur les probabilités to the Académie des Sciences </td>|
Thanks in advance for any help with this,
11-20-2012 01:47 PM
Michael, I'm not sure what you are asking. If you know what html code you want in the file, why don't you skip ods altogether and simply use a data _null_ step to create a text file with an htm or html extension?
11-20-2012 03:23 PM
Ah, thanks Art.
This gives me more or less what I want, and avoids the issues I mentioned. I think I was stuck in an ODS HTML mindset.
11-20-2012 11:28 PM
If you are familiar with html code , why not write it as a plain html file ?
filename x 'c:\want.html';
length qname $160 query $80;
Or You could edit whatever you want in MS WORD and Save as it a html file, it is a convenient way to generate a plain html.
Message was edited by: xia keshan