1 / 26

David Ghan Technical Training Specialist SAS, Canada

Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format. David Ghan Technical Training Specialist SAS, Canada. Objective demonstrate the power of Proc Template to customize SAS output format

badrani
Download Presentation

David Ghan Technical Training Specialist SAS, Canada

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format David GhanTechnical Training SpecialistSAS, Canada

  2. Objective • demonstrate the power of Proc Template to customize SAS output format • outline the general framework for how this is done and introduce some key concepts for starting with Proc Template.

  3. Output Delivery System (ODS) FLEXIBILITY

  4. ODS Destinations Report Destinations Listing HTML RTF Printer Data Destination Output

  5. Data Component OutputObject Template Components ODS Output Production Destination Result SASData Set Output Window HTMLFile RFT File Output Listing HTML RTF * Pre-defined templates provided, but can customize

  6. Why Use ODS and Proc Template? • form and appearance matter. • automate the formatting process • production jobs • applications • make results accessible to users in their preferred form. • no post-production point-and-click.

  7. Template Types • Table • column • header • footer • Style • Presentation • Colors • Fonts • There are specific table template for each type of output object. • A single style template affects the general look of all the output within a given document.

  8. The general structure of templates style template table template header footer column table style elements attributes attributes attributes attributes attributes values values values values values

  9. Objectives • projected airfares on all flight routes in 3 seat classes over 4 years. • a frequency report for number of employees in different job classes. SAS text output Projected Ticket Rates Route First Class Business Economy First Class Business Economy Number Fare Year 1 Fare Year1 Fare Year1 Fare Year2 Fare Year2 Fare Year2 0000001 $1,600.00 $1,090.00 $531.00 $1,942.00 $1,323.00 $645.00 0000002 $1,600.00 $1,090.00 $531.00 $1,942.00 $1,323.00 $645.00 0000003 $1,761.00 $1,201.00 $585.00 $2,139.00 $1,458.00 $711.00 0000004 $1,761.00 $1,201.00 $585.00 $2,139.00 $1,458.00 $711.00 0000005 $176.00 $120.00 $58.00 $213.00 $145.00 $71.00 0000006 $176.00 $120.00 $58.00 $213.00 $145.00 $71.00 . . . . . . . . . . . . . . Counts by Job Code Job Code Job Cumulative Cumulative Code Frequency Percent Frequency Percent ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ BAGCLK 140 6.76 140 6.76 BAGSUP 18 0.87 158 7.63 CHKCLK 125 6.04 283 13.67 CHKSUP 18 0.87 301 14.54 FACCLK 124 5.99 425 20.53 . . . . . . . . . .

  10. Objectives (cont’d) • Create the SAS output in HTML format and RTF (Rich Text Format) using standard templates supplied by SAS. RTF HTML • Create and use modified templates to produce the HTML and RTF output. RTF HTLM • font • color • traffic lighting • heading text • data formats • order of columns • banner image (HTLM) • background image (HTML) • panels (RTF) • page orientation (RTF)

  11. The Plan: Step 1 - create procedure output as text. Step 2 - create RTF and HTML output with “default” templates.

  12. The Plan: • Step 3 - Part A -modify style template to specify: • font • font size • landscape layout (RFT) • banner and background images (HTML). • Part B - apply new style template to create output. • Step 4 - Part A - modify table template for Proc Freq to specify: • order and format of columns • header text • 2 panels per page (RTF) • traffic lighting. • Part B - apply new table template to create output.

  13. proc report, proc freq Data Component OutputObject Template Components style template, table template ODS Output Production Destination Result SASData Set Output Window HTMLFile RTF File Output Listing HTML RTF

  14. Step 1 - create procedure output as text. procreportdata=airline.rates(obs=50) nowd split=' '; title'Projected Ticket Rates'; columns rte_id _numeric_; define rte_id / id; run; procfreqdata=airline.employees; table JobCode; title'Counts by Job Code'; run;

  15. Step 2 - create RTF and HTML output with “default” templates. ODSRTF file=‘something.rtf’; ODSHTML file=‘something.html’; <original SAS code producing output> ODS RFT CLOSE; ODS HTML CLOSE;

  16. Step 3 - Part A -modify style template to specify font, font size, landscape layout (RFT), and banner and background images (HTML). PROC TEMPLATE; DEFINE STYLE style-name;PARENT=parent;REPLACEelement1 attribute1=value attribute2=value …; REPLACE element2 attribute1=value attribute2=value …; END;RUN; Element attribute value _ document background image something.gif column headers text color blue background color white font Lucidia Console cell borders thickness 2 pixels color black

  17. Step 3 - Part B - apply new style template to create output. ODSRTF file=‘something.rtf’ style=newstyle; ODSHTML file=‘something.html’ style=newstyle; <original SAS code producing output> ODS RFT CLOSE; ODS HTML CLOSE;

  18. Step 4 - Part A - modify table template for Proc Freq to specify order and format of columns, header text, 2 panels per page (RTF), and traffic lighting. PROC TEMPLATE;EDIT TABLE template-name;MVAR; COLUMNcolumn(s);DEFINEheader;attribute1=value …; END; EDIT column; HEADER='label text'; FORMAT=format.; … other change statements…END; END;RUN; • Attributes and values can be specified for: • the entire table • table headers and footers • individual column headers and column values

  19. Step 4 - Part B - apply new table template to create output. SAS matches up the data component of each output object with the template component by name. User modified table templates retain the same name as the originals, but they are stored in a different location. By default, SAS will find and use the user defined table templates first. No need to specify the new table template. An ODS PATH statement can be used to control which templates SAS is able to find and use.

  20. Process: • what do I want to change? • what are the corresponding style elements of the style template? • (and/or) • what is the name of the table template and the names of the headers or columns within that I want to change? • what particular attributes do I want to specify for these style elements, or for the tables, table headers, or table columns? • what are valid values to set for these attributes? • *Everything in red italics has a specific name

  21. The general structure of templates style template table template header footer column table style elements attributes attributes attributes attributes attributes values values values values values This is the forest. Don’t get lost among the many trees

  22. Template inheritance: • within a style template, elements inherit attributes and their values from other elements. • both style and table templates may also inherit elements and their attributes from other templates.

  23. Inheritance within a style template: proc template; define style Styles.Default; . . . . style Container font = Fonts('DocFont') foreground = colors('docfg') background = colors('docbg'); style Index from Container foreground = colors('contentfg') background = colors('contentbg'); . . . . Inheritance from another style template: proc template; define style Styles.Rtf; parent = styles.printer; style titleAndNoteContainer from titleAndNoteContainer / outputwidth = _undef_; replace cell from container / linkcolor = colors('link2');

  24. Inheritance from another table template: proc template; edit Base.Freq.OneWayFreqs; . . .

  25. Help and documentation: • SAS Online Doc - Guide to the Output Delivery System. • includes syntax • full lists of elements, attributes, and values. • (hardcopy useful) • Interactive Template Window and Template Browser Window. • get to know the default templates you need to work with • copy and paste required code. • Classroom Training: Getting Started with the Output Delivery System.

  26. Other references: • URLs of Interest: www.sas.com/rnd/base/topics/ odsxml/xml.pdf odsprinter/faq.html odscss/ odsfordata/ods.pdf style-template/style.html v6v8ods/index.html • V7/V8 and ODS papers to download: http://ftp.sas.com/techsup/download/v7papers/

More Related