The SAS Output Delivery System and reporting techniques

Delete line break after header h1 in SAS9.1.3

Reply
N/A
Posts: 0

Delete line break after header h1 in SAS9.1.3

Hi,

I am new to SAS and to this group. I have been modifying templates so that they

produce the same output in SAS9.1.3 as they did in SAS8.2. I have used the MSOffice2K
tagset
and have almost got the desired result. The issue that I now have is, I have a

line break after each header h1.




I have defined stylesheets as below:

proc template;
define style audit;
parent=styles.default;

style SystemTitle /
font_size = 10pt
font_weight = bold
foreground = #002288
font_face = Times
Just = L
font_style = Italic;
..
.
.



---- avi.sas is the main program and its below.


ods tagsets.MSOffice2K file='New_output.xls' style=audit


title1 'test1';
title2 'test2';


......
....
...
..
.;

Proc print data=sashelp.class;
Run;
ods tagsets.MSOffice2K close;

When I open the code for the excel sheet (New_output.xls') this is what I see for the entry (Note: I have taken out the tags for h1 below as it is treating it as a header)


h1 class="SystemTitle">test1 h1
h1 class="SystemTitle">test2 h1
...
..
.


In the excel sheet I have a line break between 'test1' and 'test2' and so on.


How can I do away with this? I have spent quiet some time researching this before I have come to take help from the group.

Any advise would be appreciated!

Thanks in advance,
Cool_avi Message was edited by: Cool_avi
SAS Super FREQ
Posts: 8,866

Re: Delete line break after header h1 in SAS9.1.3

Posted in reply to deleted_user
Hi:
I'm not exactly sure I understand the problem. However, if you really liked the kind of HTML written by SAS 8.2, and it gave you the header behavior that you desire, then one simple solution is to switch -back- to that form of HTML.

In SAS 8, ODS produced HTML 3.2 compliant HTML tags. In SAS 9, ODS produces HTML 4.01 compliant HTML tags. ODS MSOFFICE2K produces Microsoft-HTML compliant tags. To "get back" to the older version of HTML, you only need to do this:

[pre]
ods html3 file='ht3_out.html' style=sasweb;
** ... your code ;
ods html3 close;
[/pre]

cynthia
[/pre]
N/A
Posts: 0

Re: Delete line break after header h1 in SAS9.1.3

Posted in reply to deleted_user
Hi Cynthia,
Thank you for your prompt reply. We were using the ODS HTML3 as you had suggested. I was assigned the responsibility to make this work with HTML4.

Let me try to explain you what the problem is. When using SAS8.2 it does
not treat this as a header. SAS 8.2 treats this something like this:


TD ALIGN=LEFT bgcolor="#E0E0E0">test1

TD ALIGN=LEFT bgcolor="#E0E0E0">test2
On the other hand SAS 9 defaults it as a h1 header like this.
h1 class="SystemTitle">test1 h1

h1 class="SystemTitle">test2 h1


As a header h1 is used I believe it might be creating a padding which is causing an extra line break between the two fields. i.e, there is a line break in the .xls sheet between title1 and title2 as seen below
title1
title2

Is there a way we can make this work with HTML4. I mean, even if h1 header is used can we suppress the blank line in the excel sheet whenever the style is being used?
SAS Super FREQ
Posts: 8,866

Re: Delete line break after header h1 in SAS9.1.3

Posted in reply to deleted_user
Hi:
Some comments:
You are NOT creating an XLS file. You are creating an HTML file that Excel knows how to open and render. Each of those files conforms to an HTML specification and Excel renders each of those files DIFFERENTLY, depending on the specification that you see at the top of each file.

So, let's remove your style template from the equation, right now. In the long run, your style template will NOT do what you want to do. Let's look at this code sample:
[pre]
ods tagsets.MSOffice2K file='mso.html' style=sasweb;
ods html3 file='ht3.html' style=sasweb;
ods html file='ht4.html' style=sasweb;

title1 'test1';
title2 'test2';
proc print data=sashelp.class (obs=3);
run;
ods _all_ close;
[/pre]

Notice that I have given the files their correct file extension of HTML. Excel will still open the files: you will either have to find the files in Windows Explorer and Right-mouse click and open with Excel, or you will have to launch Excel and navigate to where the 3 files live and then open each of them.

The fact that DIFFERENT HTML tags get written for each destination is no accident. If you opened each of the above files with Notepad, you would see the following tags at the top of each file:
[pre]
MSO.HTML (note that MSOFFICE2K is NOT creating HTML 4.01 compliant HTML tags -- the output file has no DOCTYPE at the top of the file and conforms to the Microsoft spec, not the W3C spec for HTML -- this is OK, as long as you KNOW you want to conform to the Microsoft spec.).
<html xmlns:v="urn:schemas-microsoft-com:vml">

HT3.HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

HT4.HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
[/pre]

ODS -knows- which type of HTML tags should be generated for each destination. For example, it is OK in HTML 3.2 to have embedded font and color information. That is NOT recommended by the W3C for HTML 4 files. If you want HTML 4 to act like HTML3, the easiest thing to do is just use the HTML3 destination.

Let's look further down in each of the files, now, at the ENTIRE HTML that is written for those 2 title statements:
[pre]

MSO.HTML (NOT in a TABLE tag)
<h1 class="SystemTitle" style=" text-align: center;">test1</h1>
<h1 class="SystemTitle2" style=" text-align: center;">test2</h1>


HT3.HTML (Titles ARE in a TABLE tag)
<TABLE cellspacing=1 cellpadding=1 rules=NONE frame=VOID border=0 width=100% bgcolor="#FFFFFF">
<TR>
<TD ALIGN=CENTER bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="4" color="#003399"><b>test1</b></font></TD>
</TR>
<TR>
<TD ALIGN=CENTER bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="4" color="#003399"><b>test2</b></font></TD>
</TR>
</TABLE>


HT4.HTML (Titles ARE in a TABLE tag)
<table class="SysTitleAndFooterContainer" width="100%" cellspacing="1" cellpadding="1" rules="none" frame="void"
border="0" summary="Page Layout">
<tr><td class="c SystemTitle">test1</td></tr>
<tr><td class="c SystemTitle2">test2</td></tr>
</table>

[/pre]

You can see that it is NOT just the H1 tag, it is the fact that for HTML3 and HTML4 files, the SAS titles are put inside a TABLE tag. For the MSOFFICE2K file, the SAS titles are put into <H1> tags. I can only assume this is done because it conforms to the Microsoft specification. I don't even KNOW whether Microsoft Excel would correctly render the <H1> tags if you put them inside a TABLE tag.

In order to change the type or kind of markup language that gets written out, you would change the tagset template, not the style template. If you ONLY wanted to change the underlying fonts and colors, then the issue would be to change the style template. If you like the way that the HTML 3 output looks when rendered in Excel, partly that happens because Excel "likes" the HTML3 tags and "likes" the TABLE tag around the SAS titles.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 182 views
  • 0 likes
  • 2 in conversation