BookmarkSubscribeRSS Feed
michael_friendly
Fluorite | Level 6

[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

4 REPLIES 4
art297
Opal | Level 21

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?

michael_friendly
Fluorite | Level 6

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.

art297
Opal | Level 21

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

Ksharp
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1239 views
  • 0 likes
  • 3 in conversation