Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA.

Similar presentations


Presentation on theme: "PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA."— Presentation transcript:

1 PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA

2 Stylish 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

3 Today’s Workshop Creating a custom style for your output. Fast-track approach –Just the basics of the syntax –Copy and paste the code you need

4 HANDS ON: Create HTML output 1.Open SAS v9 using the shortcut with my name on it 2.The first sample program should be open (if not, open c:\workshops\ws112\SampleProgram1.sas) 3.Submit the program

5 RESULTS

6 Syntax: the STYLE= option When we issued this ODS command: ODS HTML FILE=‘sample1.html’; We’re really issuing this command: ODS HTML FILE=‘sample1.html’ STYLE=Default;

7 Syntax: 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

8 Syntax: PROC TEMPLATE This PROC does many things related to ODS Style and Table definitions One key feature: the SOURCE statement –Allows you to view the source code for a style

9 HANDS ON: use SOURCE statement 1.In SAS, switch back to the program window 2.Use the Open button on the menu bar 3.Select SampleProgram2.sas 4.Review the syntax of the SOURCE statement 5.Submit the program 6.Switch to the log window to see the results

10 RESULTS + 700 more lines of source code!

11 PROC TEMPLATE source code Skimming through the code, you’ll see: –Many style definitions –Cover colors, fonts, titles, tables, etc. Templates like this are overwhelming to read We’ll look at another tool for understanding styles

12 HANDS ON: Pop-up Styles 1.In SAS, switch back to the program window 2.Use the Open button on the menu bar 3.Select SampleProgram3.sas 4.Find the ODS MARKUP statement

13 Tagset: style_popup This code creates HTML using a tagset: ods markup file="sample3.html" tagset=tagsets.style_popup ; The MARKUP destination and tagsets are a whole workshop All you need to know is that this technique creates an HTML file with special features

14 HANDS ON: Pop-up Styles 1.Submit the program 2.Don’t review the results in SAS 3.Instead, open Internet Explorer and open c:\workshops\ws112\sample3.html

15 RESULTS If you see the security warning on your output, right click on it, select “Allow blocked content”, and click Yes.

16 RESULTS Moving the mouse around highlights different parts of the page, and brings up a label for each part of the output. This label shows the style element that controls that part of the output.

17 RESULTS Clicking on a highlighted part of the output brings up a popup window with the style definition code

18 HANDS ON: Find this style 1.In SAS, switch back to the log window 2.Scroll up until you find the log for Sample Program 2 3.Scan through the source code for Style Header (the style we found using the popup tool)

19 RESULTS There’s nothing there. This doesn’t look like the code from the popup. Why? This code references another style “HeadersAndFooters”

20 RESULTS This still doesn’t look like the code from the popup. References another style (Cell), and two lists fonts() and colors(). Backtracking to find all of these items would be time- consuming The popup style saves this effort. It shows you all of the values in one style element

21 Changing the fonts

22 HANDS ON: Creating a Custom Style 1.In SAS, switch back to the program window 2.Use the Open button on the menu bar 3.Select SampleProgram4.sas 4.Find the PROC TEMPLATE statement 5.Find the PARENT= statement

23 Syntax: 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

24 HANDS ON: Copying a Style 1.Go back to Internet Explorer 2.Click on the title of the output 3.Find the popup window (if it’s not visible, it may be minimized) 4.Copy the code for the style SystemTitle 5.Switch back to the SAS program window

25 HANDS ON: Pasting a Style 1.Insert a blank line below the PARENT= statement 2.Paste the style code there

26 Changing Typefaces Use the style attribute FONT_FACE= Change to a new value For HTML, can list up to 3 fonts (in case your user doesn’t have your 1 st -choice font) For other destinations, only 1 is used

27 Changing Typefaces Here are some typefaces to try These are “safe” because most of your users will have them

28 HANDS ON: Changing Typefaces 1.Edit the font name in the FONT_FACE= attribute for the title style 2.Submit the program 3.View the output in the results window 4.See what changed

29 HANDS ON: Changing Typefaces Reference:

30 Changing Typefaces: My Code

31 Changing Typefaces: My Results

32 Changing Font Sizes Notice that the title and footnote are the same size. You may want to make the footnote smaller

33 HANDS ON: Copying Footnote Style 1.Go back to Internet Explorer 2.Click on the footnote of the output 3.Find the popup window (if it’s not visible, it may be minimized) 4.Copy the code for the style SystemFooter 5.Switch back to the SAS program window

34 HANDS ON: Pasting a Style 1.Insert a blank line above the END statement 2.Paste the style code there

35 Changing the font size Use the FONT_SIZE attribute The value (5) is an HTML font size You can replace it with another HTML font size, or you can switch to a value in points ( 10pt )

36 HANDS ON: Font Size 1.Use the style attribute FONT_SIZE= 2.Change the 5 to a new value

37 Changing the Font Style The footnote looks nice in italic, but the title does not We can fix that now Use the FONT_STYLE attribute Values you can use are italic and roman (non-italic)

38 HANDS ON: Font Style 1.Go to the SystemTitle style 2.Use the style attribute FONT_STYLE= 3.Change the italic to roman 4.Run the program to see the change in the title and footnote

39 Changing Font Size and Style: My Code

40 Changing Font Size and Style: My Results

41 HANDS ON: More Font Changes 1.Use the Popup tool to add the code for the column headers (Style Header) to the PROC TEMPLATE code 2.Change the typeface and style to whatever you want 3.Another attribute you can change is FONT_WEIGHT (values: medium or bold) 4.Make further changes to the headers, title, and footnote, if you like 5.Resubmit the program and review your results

42 More Font Changes: My Code

43 More Font Changes: My Results

44 HANDS ON: More Font Changes 1.Use the Popup tool to add the code for the table cells (Style Data) to the PROC TEMPLATE code 2.Change the typeface, weight, and style to whatever you want 3.Make further changes to the headers, title, and footnote, if you like 4.Resubmit the program and review your results

45 More Font Changes: My Code

46 More Font Changes: My Results

47 Changing 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

48 HANDS ON: Copying a Style 1.Go back to Internet Explorer 2.Hover the mouse over the borders until the table borders turn red 3.Copy the Table style from the popup window

49 HANDS ON: Pasting the Style 1.Go back to SAS and paste the style into your PROC TEMPLATE 2.Review the RULES= style and FRAME= style attributes

50 Changing Rules and Borders Lines between cells inside the table are controlled by the Rules style attribute Borders around the outside of the table are controlled by the Frame style attribute

51 Changing Borders The Frame attribute is currently set to BOX (borders all of the way around the table) Another option is void (no borders) Further options: –above, below, rhs, lhs (pick a side) –vsides, hsides (left and right, top and bottom)

52 HANDS ON: Changing Borders 1.Change the Frame setting to one of the other options by typing over the word box

53 Changing Rules The Rules attribute is currently set to groups (lines between table header/footer and body) Other options: –all (lines between all cells) –none (no lines between the table cells) –rows (lines between the rows) –cols (lines between the columns)

54 HANDS ON: Changing Rules 1.Change the Rules setting to one of the other options by typing over the word groups

55 Changing Rules and Borders: My Code

56 Changing Rules and Borders: My Results Wait a minute – didn’t we just set the rules to none? Where did those white lines come from?

57 Cell Spacing The lines we could see in our table did not come from the table rules They were created because the table background (white) was showing through between the table cells If the CELLSPACING attribute is >0, then the background shows through

58 HANDS ON: Cell Spacing 1.Go back to the SAS program and change the CELLSPACING setting in the Table style to 0 2.Submit the program

59 Cell Spacing: My Code

60 Cell Spacing: My Results

61 Cell Padding One more attribute is available for tables: CELLPADDING Cell padding puts space inside table cells, between the text and the cell borders Larger values make table more readable Smaller values save space

62 HANDS ON: Cell Padding 1.Go back to the SAS program and change the CELLPADDING setting in the Table style 2.Submit the program

63 Cell Spacing: My Code

64 Cell Padding: My Results

65 Changing 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

66 Changing the Color Scheme *Warning: some color names have typos in SAS, will get warning messages

67 Changing the Color Scheme To assign a new color: –Pick the correct style element (SystemTitle, SystemFooter, Header, Data) –change the FOREGROUND and BACKGROUND values to the colors you want

68 HANDS ON: Changing the Colors 1.Go back to the PROC TEMPLATE code 2.In the SystemTitle style, type over the hex code for FOREGROUND with the text “red” (minus the quotes 3.Re-run the program and see what happens

69 HANDS ON: Changing the Colors

70 Changing Colors: My Code

71 Changing Colors: My Results

72 HANDS ON: Changing More Colors 1.Go back to the PROC TEMPLATE code 2.Change more of the FOREGROUND and BACKGROUND settings 3.Re-run the program and see what happens

73 HANDS ON: Changing the Colors

74 Changing Colors: My Code For SystemTitle, SystemFooter, and Header: FOREGROUND = midnightblue BACKGROUND = white For Data and Table: FOREGROUND = black BACKGROUND = white

75 Changing Colors: My Results Why is the background still gray? We need to add one more style element to our code

76 HANDS ON: Copy/Paste Code 1.Go back to Internet Explorer 2.Click on the background of the page (hint: look at the parts of your output that still have that gray color, and click on the same area in Internet Explorer) 3.Copy the code from the popup (style Body) and paste it into your PROC TEMPLATE

77 HANDS ON: Change the Body Colors 1.Edit the colors in the Body style element to your choices 2.Rerun the program

78 HANDS ON: Changing the Colors

79 Changing Colors: My Code

80 Changing Colors: My Results What are those faint gray boxes around the title and footnote?

81 Removing the Boxes This exposes one limitation to using the popup styles: –You can’t click on these boxes, so there’s no way to find out what code to modify –Solution is in my paper: STYLE SysTitleAndFooterContainer / CELLSPACING=0;

82 Removing the Boxes: My Results

83 Changing 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 you’re not creative, try http://www.colorschemer.com/online/

84 RTF differences Instead of Default style as parent, use RTF RTF has very narrow page margins (0.25”). –To change: add style attributes TOPMARGIN, BOTTOMMARGIN, LEFTMARGIN, and RIGHTMARGIN to the Body style element. Set them to a larger value (e.g. 1in). You don’t need to list multiple font names If you are rerunning an ODS RTF program, you need to close the Results window before resubmitting the job Titles and footnotes will appear in the page header and footer, unless you add the option BODYTITLE to your ODS RTF statement Sample Program 5 shows these changes

85 PDF differences Instead of Default style as parent, use Printer If you get a WARNING message “'Font specification " " failed', you may need to register the fonts on your system. Execute the following code to fix the problem: proc fontreg; fontpath "%sysget(systemroot)\fonts"; run; You don’t need to list multiple font names If you are rerunning an ODS PDF program, you need to close the Results window before resubmitting the job Sample Program 6 shows these changes

86 Summary You’ve 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 don’t need to run it every time (read up on the ODS PATH statement)

87 Summary Some warnings: –The Popup style is very simple –To modify very specific portions of your output, you will need to add more style elements and settings –RTF and PDF are a little different

88 References (no need to write down, they’re all in the proceedings) PROC TEMPLATE documentation: –SAS Output Delivery System Users Guide (version 9.1.3 online documentation) http://support.sas.com/onlinedoc/913/docMainpage.jsp A CD of additional sample styles: –Bernadette Johnson, Instant ODS: Style Templates for the SAS Output Delivery System, © 2003, BBU Press, Cary, NC, USA. Preliminary documentation of new features and sample programs can be found at: –http://www.sas.com/rnd/base/index-ods-resources.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.

89 FINAL HANDS ON: Tweak your Style I’ll be happy to take your questions at this point, or … You can use the remaining time to continue to modify your style Or, you can play with sample programs 5 and 6 THANKS FOR COMING!

90 COLOR REFERENCE www.laurenhaworth.cominfo@laurenhaworth.com


Download ppt "PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA."

Similar presentations


Ads by Google