| TEMPLATE Procedure: Creating a Style Template (Definition) |
| PROC TEMPLATE features: |
| |||||||||
| Other ODS features: |
|
| Program Description |
The following program imports the external CSS file StyleSheet.css and converts the CSS code into style elements and style attributes. These style elements and attributes then become part of the style.
Your CSS file can contain media blocks that correspond to the type of media that your output will be rendered on. The IMPORT statement allows you to specify one or more media blocks to be imported along with the rest of the CSS code. In this example, the Print media block is included in the style that is applied to the PDF output.
| Program |
options nodate pageno=1 linesize=80 pagesize=40 obs=10;
| |
proc template;
define style styles.mycssstyle;
import "StyleSheet.css";
class data /
color = red;
end; |
| |
define style styles.mycssstyleprinter;
parent=styles.mycssstyle;
import "StyleSheet.css" print;
end;
run; |
| |
ods html file="css.html" style=styles.mycssstyle; ods pdf file="css.pdf" style=styles.mycssstyleprinter; proc contents data=sashelp.class; run; |
| |
ods _all_ close; |
| Output |
proc template;
define style Styles.Mycssstyle / store = SASUSER.TEMPLAT;
class body /
fontfamily = "times, serif"
color = #000000
backgroundcolor = #FFFFFF;
class header /
backgroundcolor = #008000
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class rowheader /
backgroundcolor = #008000
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class footer /
backgroundcolor = #008000
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class rowfooter /
backgroundcolor = #A0A0A0
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #000000
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class data /
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = red
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class table /
fontsize = 3
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px
borderspacing = 0
backgroundcolor = #FFFF00;
class proctitle /
fontweight = medium
fontsize = 6
fontfamily = "helvetica, sans-serif";
end;
run;
MyCssStyle Style Applied to HTML Output
| |
|
proc template;
define style Styles.Mycssstyleprinter / store = SASUSER.TEMPLAT;
parent = styles.mycssstyle;
class body /
fontfamily = "times, serif"
color = #000000
backgroundcolor = #FFFFFF;
class header /
backgroundcolor = #0000FF
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class rowheader /
backgroundcolor = #0000FF
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class footer /
backgroundcolor = #0000FF
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #FFFFFF
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px; class rowfooter /
backgroundcolor = #A0A0A0
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #000000
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class data /
fontsize = 3
fontfamily = "times, serif"
paddingleft = 5px
paddingbottom = 5px
paddingright = 5px
paddingtop = 5px
color = #000000
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px;
class table /
borderleftstyle = solid
borderleftcolor = #000000
borderleftwidth = 1px
borderbottomstyle = solid
borderbottomcolor = #000000
borderbottomwidth = 1px
borderrightstyle = solid
borderrightcolor = #000000
borderrightwidth = 1px
bordertopstyle = solid
bordertopcolor = #000000
bordertopwidth = 1px
borderspacing = 0
backgroundcolor = #DDDDDD;
class proctitle /
fontweight = medium
fontsize = 6
fontfamily = "helvetica, sans-serif";
end;
run;
MyCssStylePrinter Style Applied to PDF Output
| |
|
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.