www.sas.com > SAS UK > In the Know Homepage Search | Contact Us     
SAS UK Newsletter Banner SAS - The power to know(tm)  

How do I change the table cell borders using BASE ODS HTML?

In this example we are using BASE ODS to create a report in html format. The example uses CSS (Cascading Style Sheets) style properties and the HTMLSTYLE attribute with the border parameter to enhance the table borders. A CSS is a simple mechanism for adding styles such as fonts, colours, margins etc., to an HTML file. The HTMLSTYLE= attribute is used to define a style locally in a tag (that is, an inline style) instead of embedded it in a <style> block or externally in a CSS file.

The ODS code below shows how you can change the style of the cell borders for each column within the sample CLASS dataset using Proc Report to create your table and BASE ODS HTML code to modify the output.


/* Use ODS syntax to write to a HTML format file */
ods html file="d:\temp\report.html"; 

/* Define how you would like the columns and headers displayed e.g. Font, Font sizes, Colours etc */

proc report data=sasuser.class nowd split='#' 
style(header)=[font_face=arial font_size=3.5 
foreground=blue background=beige borderwidth=5px bordercolor=green] 
style(column)=[font_face=optima foreground=black background=white cellwidth=30]; 

/* Define which columns you would like to appear in the report */

column name weight age height; 

define name / display ; 
define weight / display ; 
define age / display ; 
define height / display; 

/* Use CSS style properties to specify how you would like the borders displayed for each column */

compute name; 
call define ('name', "style", 
'style={htmlstyle="border-bottom: 3px dotted green;border-left: 2px dotted green; 
border-right: 2px dotted green ;border-top: none"}'); 
endcomp; 

compute weight; 
call define ('weight', "style",
'style={htmlstyle="border-bottom:2px solid brown;border-left: 3px solid brown; 
border-right: 3px solid brown;border-top: none"}'); 
endcomp; 

compute age; 
call define ('age', "style", 
'style={htmlstyle="border-bottom:2px solid blue;border-left: 2px solid blue; 
border-right: 2px solid blue ;border-top: none"}'); 
endcomp; 

compute height; 
call define ('height', "style", 
'style={htmlstyle="border-bottom:3px dashed red ;border-left: 3px dashed red; 
border-right: 3px dashed red;border-top: none"}'); 
endcomp; 

run; 

ods html close; 
This example is not applicable for RTF and PDF output formats.
For more examples of using the Output Delivery System, please visit the following website:
http://support.sas.com/rnd/base/index-ods-resources.html