The SAS Output Delivery System and reporting techniques

ods html text in SAS 9.4

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 156
Accepted Solution

ods html text in SAS 9.4

Dear all,

 

We are migrating to SAS 9.4 from SAS 9.2. And I found a difference in the ods html text output, please see code below:

 

SAS 9.2

 

ods html file='C:\data\test.html'(no_top_matter no_bottom_matter);

ods html text="This is a test.";

ods html close;

 

generates this html output:

 

<div class="l UserText">This is a test.</div>

 

SAS 9.4 same code, html output:

 

<table width="100%" style=" border: 0px solid #000000; border-spacing: 0px;" cellspacing="0" cellpadding="0" rules="none" frame="void">

<tr>

<td class="l usertext">This is a test.</td>

</tr>

</table>

 

This is a problem for me because I have a html output where I generate 3 report and use this layout (with html <table>): first row: 2 reports next to each other. Second row: 3rd report below the first 2 reports from row 1. I programmed it like this:

 

Ods html text = “<table>”;

 

Ods html text =” <tr>”;

Ods html text = “ <td>”;

%output_report1;

Ods html text = “ </td>”

Ods html text = “ <td>”;

%output_report2;

Ods html text = “ </td>”;

Ods html text =” </tr>”;

 

Ods html text = “ <tr>”;

Ods html text = ” <td colspan=’2’>”;

%output_report3;

Ods html text = “ </td>”;

Ods html text =” </tr>”;

 

Ods html text = “</table>”;

 

With the new surrounding code of ods html text in SAS 9.4 this does no longer works and returns a real weird output/layout.

 

So my question is: Is there a way to tell ods html text to react like in SAS9.2 and not to use the <table> Code around my text?

 

Best wishes

Eva


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
SAS Super FREQ
Posts: 699

Re: ods html text in SAS 9.4

Hi Eva

 

Have a look at the ODS LAYOUT functionality.

 

The sample below shows an example, how to use it.

 

ods html file="c:\temp\sample.html";

ods layout gridded columns=2;
ods region;
title "title 1";
  proc print data=sashelp.class(obs=5);
    where sex = "F";
  run;

ods region;
title "title 2";
  proc print data=sashelp.class(obs=5);
    where sex = "F";
  run;

ods region column_span=2;
title "title 2";
  proc print data=sashelp.cars(obs=10);
  run;

ods layout end;
ods html close;

View solution in original post


All Replies
Solution
‎09-25-2015 06:23 AM
SAS Super FREQ
Posts: 699

Re: ods html text in SAS 9.4

Hi Eva

 

Have a look at the ODS LAYOUT functionality.

 

The sample below shows an example, how to use it.

 

ods html file="c:\temp\sample.html";

ods layout gridded columns=2;
ods region;
title "title 1";
  proc print data=sashelp.class(obs=5);
    where sex = "F";
  run;

ods region;
title "title 2";
  proc print data=sashelp.class(obs=5);
    where sex = "F";
  run;

ods region column_span=2;
title "title 2";
  proc print data=sashelp.cars(obs=10);
  run;

ods layout end;
ods html close;
Regular Contributor
Regular Contributor
Posts: 156

Re: ods html text in SAS 9.4

Dear Bruno,

 

thanx for the example. Looks easy. I'll try that one.

 

But generally is there a way (maybe through sas templates) to influence the ods html text - i.e. to remove the <table> around it? Unfortunately I have never used that but heard about it.

 

Best wishes

Eva

SAS Super FREQ
Posts: 8,781

Re: ods html text in SAS 9.4

Hi:
Unfortunately, it is NOT the style template that determines which HTML tags get written to the output file. That is the job of the TAGSET template that controls the ODS destination "markup" language that is written around the output from the SAS procedure.. If you want to alter the HTML that is automatically written by ODS, then you either need to switch to a different HTML-based destination or work with Tech Support or explore Bruno's suggestion for using ODS LAYOUT/ODS REGION or explore Kurt's suggestion of using DATA _NULL_.

cynthia
Regular Contributor
Regular Contributor
Posts: 156

Re: ods html text in SAS 9.4

Dear Cythia,

 

thanks for the answer. A pity though that I can't change it.I prefered the <div> around the text to the <table>, because logically a text has nothing to do with a table.

I'll use Bruno's suggestion then with the ods layout.

 

Best wishes

Eva

Super User
Posts: 7,101

Re: ods html text in SAS 9.4

Close the HTML destination, use DATA _NULL_ steps to write your text to the file, and re-open the HTML destination with FILENAME MOD.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Regular Contributor
Posts: 156

Re: ods html text in SAS 9.4

[ Edited ]

So now that I know I can't change the way ods html text is written into the html code I use this solution:

 

 

data _null_;
     file _webout;
     put "<table>";
     put " <tr>";
     put "  <td>";
run;

......

data _null_;
     file _webout;
     put "  </td>";
     put " </tr>";
     put "</table>";
run;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 1650 views
  • 0 likes
  • 4 in conversation