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
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;
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;
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
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
Close the HTML destination, use DATA _NULL_ steps to write your text to the file, and re-open the HTML destination with FILENAME MOD.
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.