Title: SAS With Style: Creating your own ODS Style Template
1SAS With Style Creating your own ODS Style
Template
- Lauren Haworth
- Genentech, Inc.
- South San Francisco, CA
2Stylish ODS
- ODS ships with standard styles
- Get the job done
- Not exactly stylish
- You can build your own styles
- To suit your taste
- To meet your business requirements
3Todays Workshop
- Creating a custom style for your output.
- Fast-track approach
- just the basics of the syntax
- will customize a simple template, which you can
take home
4Syntax the STYLE option
- If you issue this ODS command
- ODS HTML BODYbody.html
- Youre really issuing this command
- ODS HTML BODYbody.html STYLEDefault
5Syntax the STYLE option
- ODS has a default style it uses for each
destination - To switch to another style, type in an explicit
STYLE option and specify a style name
6Syntax PROC TEMPLATE
- Allows you to define every aspect of a style
- Can contain hundreds of lines of code.
- To simplify life, we build styles from existing
styles - use the PARENT statement
- only specify the things we want to change
7Syntax PROC TEMPLATE
- Teaching TEMPLATE would require a much longer
course - Were going to cheat by learning to modify a
sample program - Will cover only the minimum syntax youll need to
get by
8HANDS ON Open Sample Program
- Open SAS v8.2
- Open sample program c\workshop\ws195\SampleProgra
m.sas - Dont run or edit the program right now
- Just follow along through the program as I
briefly explain the code - Some parts of the code will be easier to see on
your computer than on my slides
9Example Program define style
- The first section of code
- sets up the name of the style (Custom)
- bases the new style on the Default style
proc template define style Styles.Custom paren
t Styles.Default
10Example Program style fonts
- The next section of code
- sets up a list of font names and characteristics.
- used later in the program as a shorthand way to
specify fonts.
style fonts from fonts / 'TitleFont'("Arial,Helv
etica,Helv",14pt,Bold Italic) 'TitleFont2'("Aria
l,Helvetica,Helv",12pt,Bold Italic) 'StrongFont'
("Arial, Helvetica, Helv",12pt,Bold) 'EmphasisFon
t'("Arial,Helvetica,Helv",10pt,Italic) 'headingF
ont'("Arial, Helvetica, Helv",12pt,Bold) 'docFon
t'("Arial, Helvetica, Helv",11pt) 'footFont'("A
rial, Helvetica, Helv",8pt)
11Example Program style fonts
- style statement
- used to supply attributes to the style element
called fonts. - from fonts syntax overwrites and adds
attributes to an existing style element
style fonts from fonts / 'TitleFont'("Arial,Helv
etica,Helv",14pt,Bold Italic) 'TitleFont2'("Aria
l,Helvetica,Helv",12pt,Bold Italic) 'StrongFont'
("Arial, Helvetica, Helv",12pt,Bold) 'EmphasisFon
t'("Arial,Helvetica,Helv",10pt,Italic) 'headingF
ont'("Arial, Helvetica, Helv",12pt,Bold) 'docFon
t'("Arial, Helvetica, Helv",11pt) 'footFont'("A
rial, Helvetica, Helv",8pt)
12Example Program style fonts
- font attributes
- font name ( alternates)
- font size
- font style/weight/width
style fonts from fonts / 'TitleFont'("Arial,Helv
etica,Helv",14pt,Bold Italic) 'TitleFont2'("Aria
l,Helvetica,Helv",12pt,Bold Italic) 'StrongFont'
("Arial, Helvetica, Helv",12pt,Bold) 'EmphasisFon
t'("Arial,Helvetica,Helv",10pt,Italic) 'headingF
ont'("Arial, Helvetica, Helv",12pt,Bold) 'docFon
t'("Arial, Helvetica, Helv",11pt) 'footFont'("A
rial, Helvetica, Helv",8pt)
13Example Program replace color_list
- The next section of code
- Sets up a shorthand list of color codes
replace color_list / 'fgB2' blue / links
/ 'fgB1' darkmagenta / visited links
/ 'fgA1' black / table cell foreground
/ 'bgA3' lightgrey / table cell background
/ 'bgA1' lightgrey / table background
/ 'fgR' darkblue / row header foreground
/ 'bgR' darkgray / row header background
/ 'fgA2' darkblue / column header foreground
/ 'bgA2' darkgray / column header background
/ bgP white / page background
/ 'fgA' navy / foreground other / 'bgA'
white / background other /
14Example Program replace color_list
- The next section of code
- Replaces color definitions from the default style
with new colors
replace color_list / 'fgB2' blue / links
/ 'fgB1' darkmagenta / visited links
/ 'fgA1' black / table cell
foreground / 'bgA3' lightgrey / table cell
background / 'bgA1' lightgrey / table
background / 'fgR' darkblue / row header
foreground / 'bgR' darkgray / row header
background / 'fgA2' darkblue / column header
foreground / 'bgA2' darkgray / column header
background / bgP white / page
background / 'fgA' navy / foreground
other / 'bgA' white / background
other /
15Example Program replace color_list
- Color_list usage
- Cryptic code names used by the parent style to
assign colors to various parts of the output
replace color_list / 'fgB2' blue / links
/ 'fgB1' darkmagenta / visited links
/ 'fgA1' black / table cell
foreground / 'bgA3' lightgrey / table cell
background / 'bgA1' lightgrey / table
background / 'fgR' darkblue / row header
foreground / 'bgR' darkgray / row header
background / 'fgA2' darkblue / column header
foreground / 'bgA2' darkgray / column header
background / bgP white / page
background / 'fgA' navy / foreground
other / 'bgA' white / background
other /
16Example Program replace Output
- The next section of code
- replaces style element that controls borders,
rules, and spacing - not a list of codes, but the actual settings
replace Output from Container / frame void
/ outside borders / rules none
/ internal borders / borderwidth 1pt /
width of borders and rules / bordercolor
color_list('fga1') / border color
/ cellpadding 7pt / space around cell
contents / cellspacing 0pt / space between
table cells /
17Example Program remaining styles
- IGNORE the next section of code
- will not be covered in this workshop
- uses the colors and fonts to modify a number of
other style elements - do not make any changes to this section
18Example Program end of template
- Final section of template code
- end terminates the style definition
- run executes the style definition, creating
styles.custom
endrun
19Example Program options
- Code after the PROC TEMPLATE
- system and ODS options
- remove The FREQ Procedure
options nodate nonumberods noptitle
20Example Program ODS output
- Final section of program
- Generate simple frequencies, send to HTML
destination - Note the styleCustom option
ods html file'c\workshop\ws195\body.html'
styleCustom title 'My Sample Title'
footnote 'My Sample Footnote' proc freq
datasashelp.class tables sex runods
html close
21HANDS ON Try It
- Submit the program
- Look at the log window to see the message about
the creation of a new style - View the HTML file
- Depending on SAS configuration, it may pop up
automatically, or - Use the SAS Results Explorer
22HANDS ON View the Results
23HANDS ON Summary
- This custom style looks a lot like the default
style - In fact its based on that style
- For the remainder of the workshop, well be
customizing this style
24Changing Typefaces
- To change the fonts
- find the part of the font specification you need
to modify
25Changing Typefaces
- Here are some typefaces to try
- These are safe because most of your users will
have them
26HANDS ON Changing Typefaces
- Scroll down through the PROC TEMPLATE code to the
style fonts from fonts definition - For each font style, type over the existing
typeface(s) with your choice of typeface - Re-run the program and see what happens
27HANDS ON Changing Typefaces
28Changing Typefaces My Results
- style fonts from fonts /
- 'TitleFont' ("Comic Sans MS, Arial,
Helvetica",14pt,Bold Italic) - 'TitleFont2' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold Italic) - 'StrongFont' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold) - 'EmphasisFont' ("Comic Sans MS, Arial,
Helvetica",10pt,Italic) - 'headingFont' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold) - 'docFont' ("Trebuchet MS, Arial,
Helvetica",11pt) - 'footFont' ("Arial, Helvetica, Helv",8pt)
29Changing Typefaces My Results
30Changing Font Sizes
- To change the fonts
- find the part of the font specification you need
to modify
31Changing Font Sizes
- Once youve found the part you need to modify
- pick a new font size
- listed in points
- important to keep relative sizes the same
(titles larger than body text) - type over the old font size with the new font size
Simplification for this workshop, other units
can be used
32HANDS ON Changing Font Sizes
- For each font style, type over the existing font
size with your choice of size - Re-run the program and see what happens
33HANDS ON Changing Font Sizes
34Changing Font Sizes My Results
- style fonts from fonts /
- 'TitleFont' ("Comic Sans MS, Arial,
Helvetica",18pt,Bold Italic) - 'TitleFont2' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold Italic) - 'StrongFont' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold) - 'EmphasisFont' ("Comic Sans MS, Arial,
Helvetica",10pt,Italic) - 'headingFont' ("Comic Sans MS, Arial,
Helvetica",11pt,Bold) - 'docFont' ("Trebuchet MS, Arial,
Helvetica",10pt) - 'footFont' ("Arial, Helvetica, Helv",8pt)
35Changing Font Sizes My Results
36Changing Font Weights
- Same process as with font size
- find the part of the font specification you need
to modify - pick a new font weight
- modify the font specification
37Changing Font Weights
- Font weight/width specification
- Four possible settings
- Bold
- Bold Italic
- Italic
- blank
There are other options, but they are not
supported by all typefaces
38HANDS ON Changing Font Weights
- For each font style, type over the existing font
weights with your choice of weight - Note if font weight is currently blank, you need
to add a comma followed by the new font weight - Re-run the program and see what happens
39HANDS ON Changing Font Weights
40Changing Font Weights My Results
- style fonts from fonts /
- 'TitleFont' ("Comic Sans MS, Arial,
Helvetica",18pt,Bold) - 'TitleFont2' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold) - 'StrongFont' ("Comic Sans MS, Arial,
Helvetica",12pt,Bold) - 'EmphasisFont' ("Comic Sans MS, Arial,
Helvetica",10pt,Italic) - 'headingFont' ("Comic Sans MS, Arial,
Helvetica",11pt,Bold) - 'docFont' ("Trebuchet MS, Arial,
Helvetica",10pt) - 'footFont' ("Arial, Helvetica, Helv",8pt,
Italic)
41Changing Font Weights My Results
42Changing the Color Scheme
- ODS allows you to specify foreground (text) and
background colors - Can use color names red, green, blue
- Or color hex codes cxFF0000, cx00FF00, cx0000FF
43Changing the Color Scheme
Warning some color names have typos in SAS,
will get warning messages
44Changing the Color Scheme
- To assign a new color
- find the area you want to modify
- change the fg and bg values to the colors you
want
45HANDS ON Changing the Colors
- Scroll down to the replace color_list section
of code. - For each named color (fgB2, fgB1, etc.),edit the
named color to your choice of color - Re-run the program and see what happens
46HANDS ON Changing the Colors
Warning some color names have typos in SAS,
will get warning messages
47Changing Colors My Results
- replace color_list /
- 'fgB2' blue
- 'fgB1' darkmagenta
- 'fgA1' orchid
- 'bgA3' lime
- 'bgA1' white
- 'fgR' lime
- 'bgR' darkorchid
- 'fgA2' lime
- 'bgA2' darkorchid
- 'fgA' deeppink
- 'bgA' white
- 'bgP' white
48Changing Colors My Results
49Changing Colors More Tips
- Find a Color Picker on the web (Google search
on this term) - use the 216-color web-safe palette
- will help you use hex codes instead of names for
more control - If youre not creative, try http//www.colorscheme
r.com/online/
50Changing Rules and Borders
- Rules are the lines between table cells
- Borders are the lines around tables, table
headers, and table footers - Virtually all ODS output is in the form of tables
51Changing Rules and Borders
- Rules are controlled by the Rules style attribute
- Borders are controlled by the Frame style
attribute - Both of these attributes are in the Output style
element in our program
52Changing Borders
- The Frame attribute is currently set to void (no
borders around the table) - Another option is box (puts a border around the
entire table) - Further options
- above, below, rhs, lhs (pick a side)
- vsides, hsides (left and right, top and bottom)
53HANDS ON Changing Borders
- Change the Frame setting one of the other options
by typing over the word void - Re-run the program and see what happens
54Changing Borders My Results
- replace Output from Container /
- frame box
- rules none
- borderwidth 1pt
- bordercolor color_list('fga1')
- cellpadding 7pt
- cellspacing 0pt
55Changing Borders My Results
Its hard to see with this color scheme, but
there is now a border around the table.
56Changing Rules
- The Rules attribute is currently set to none (no
lines between the table cells) - Other options
- all (lines between all cells)
- groups (lines between table header/footer and
body)
57HANDS ON Changing Rules
- Change the Rules setting to all or groups by
typing over the word none - Re-run the program and see what happens
58Changing Rules My Results
- replace Output from Container /
- frame box
- rules all
- borderwidth 1pt
- bordercolor color_list('fga1')
- cellpadding 7pt
- cellspacing 0pt
59Changing Rules My Results
60Changing Line Widths and Colors
- Frame and Rules control what lines you get
- They do not control line width or color
- Borderwidth and Bordercolor control line
appearance
61Changing Line Widths and Colors
- Borderwidth takes a line width in points
- Its currently set to 1pt
- It only affects the table border, not the rules
between cells
62Changing Line Widths and Colors
- Bordercolor can be set to one of the pre-defined
colors - bordercolor color_list(fga1)
- It can also be set to a color name directly
- bordercolor white
- Unlike Borderwidth, Bordercolor works on both
borders and rules
63HANDS ON Changing Lines
- Change the Borderwidth to a new value by typing
over the 1 with a new width - Change the Bordercolor to a new value by
replacing fga1 with a different item from the
color list, or typing in a color name - Re-run the program and see what happens
64Changing Lines My Results
- replace Output from Container /
- frame box
- rules all
- borderwidth 2pt
- bordercolor black
- cellpadding 7pt
- cellspacing 0pt
65Changing Lines My Results
66Changing Table Spacing
- Cellpadding puts space inside table cells,
between the text and the cell borders - Larger values make table more readable
- Smaller values save space
67HANDS ON Changing Table Spacing
- Change the Cellpadding setting by typing over the
7 with a new value - Re-run the program and see what happens
68Changing Table Spacing My Results
- replace Output from Container /
- frame box
- rules none
- borderwidth 2pt
- bordercolor black
- cellpadding 3pt
- cellspacing 0pt
69Changing Table Spacing My Results
The change can be hard to see, but the impact on
the overall table size is significant.
70Summary
- Youve now learned the basics of style
modification fonts, colors, rules/borders,
spacing - These techniques will allow you customize most
aspects of your output - You can save your PROC TEMPLATE code, but you
dont need to run it every time (read up on the
ODS PATH statement)
71Summary
- Some warnings
- This is an extremely simple example style
- To modify very specific portions of your output,
you will need to add more style elements and
settings
72References(no need to write down, theyre all in
the proceedings)
- PROC TEMPLATE documentation is in the References
chapter of - Guide to the Output Delivery System in SAS Online
Doc, version 8, ?1999, SAS Institute Inc., Cary,
NC, USA. - Preliminary documentation of new features and
sample programs can be found at - http//support.sas.com/rnd/base/index-ods-resource
s.html - My book on ODS has a number of chapters on
modifying ODS styles - Haworth, Lauren, Output Delivery System The
Basics, ?2001, SAS Institute Inc., Cary, NC, USA.
73FINAL HANDS ON Tweak your Style
- Ill be happy to take your questions at this
point, or - You can use the remaining time to continue to
modify your style - THANKS FOR COMING!
74COLOR REFERENCE
Warning some color names have typos in SAS,
will get warning messages