Help using Base SAS procedures

ODS HTML: generate a totally raw HTML file / character encoding issues

Reply
Contributor
Posts: 24

ODS HTML: generate a totally raw HTML file / character encoding issues

[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"

              (no_top_matter no_bottom_matter

               title='Milestones Calendar Events')

              options(pagebreak='no')

              ;

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>

<p>

<table columns="1" cellpadding="2" border="1">

<tr><td>

<pre><html> 

In addition, one of my data sources have accented characters encoded in HTML entities, e.g., &eacute;  while the other has them

encoded in latin1, e.g., é.  In the output HTML file, with HTML entities, I get entries like this:

<tr>                                                                                                              
  <td class="day">10 </td>                                                                                        
  <td><img src='tombstone.png' width=24> </td>                                                                    
  <td>died: &Eacute;mile Cheysson 1910 (Leysin, Switzerland) </td>                                                
</tr>                                                                                                             

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.

<tr>                                                                                                              
  <td class="day">14 </td>                                                                                        
  <td><img src='calendar.png' width=24> </td>                                                                     
  &lt;td&gt;event: Pierre Simon Laplace 1814                                                                            
Laplace presents Essai philosophique sur les probabilités to the Académie des Sciences &lt;/td&gt;                      
</tr>                                                                                                             

Thanks in advance for any help with this,

-Michael

a

Attachment
Attachment
Attachment
Attachment
PROC Star
Posts: 7,363

Re: ODS HTML: generate a totally raw HTML file / character encoding issues

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?

Contributor
Posts: 24

Re: ODS HTML: generate a totally raw HTML file / character encoding issues

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.

PROC Star
Posts: 7,363

Re: ODS HTML: generate a totally raw HTML file / character encoding issues

Excellent!  Now when can I get you to do a presentation at one of the TASS meetings?

Super User
Posts: 9,681

Re: ODS HTML: generate a totally raw HTML file / character encoding issues

Michael,

If you are familiar with html code , why not write it as a plain html file ?

filename x 'c:\want.html';

data _null_;

    file x;

    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.

Ksharp

Message was edited by: xia keshan

Ask a Question
Discussion stats
  • 4 replies
  • 377 views
  • 0 likes
  • 3 in conversation