Customize your SAS® Output with the Template Procedure: A Beginning Tutorial Carol Gosselin North Carolina State University, Raleigh, NC Joy Munk Smith.

Slides:



Advertisements
Similar presentations
Introduction to Web Design Lecture number:. Todays Aim: Introduction to Web-designing and how its done. Modelling websites in HTML.
Advertisements

Internet Services and Web Authoring (CSET 226) Lecture # 5 HyperText Markup Language (HTML) 1.
Cascading Style Sheets (CSS). Cascading Style Sheets With the explosive growth of the World Wide Web, designers and programmers quickly explored and reached.
 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
The Web Warrior Guide to Web Design Technologies
How to Create a Custom Style Sonia Extremera / Antonio Nieto / Javier Gómez PhUSE Annual Conference, 9th-12th Oct 2011, Brighton UK.
MIS 425 Lecture 1 – HTML Basics and Web Page Design Instructor: Martin Neuhard
13 February Building a Web Page. HTML Files Two types of information Text Instructions on how to display Instructions are in the form of tags Tags are.
1 Getting Started with CSS. 2 CSS Cascading Style Sheets XHTML provides structure for our documents (web pages) CSS provides Style or Presentation for.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Introduction to HTML 2006 CIS101. What is the Internet? Global network of computers that are connected and communicate via a series of Protocols Protocols.
Python and Web Programming
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
CIS101 Introduction to Computing Week 06. Agenda Your questions Excel Exam during second hour Our status after the snow day Introduction to the Internet.
Creating and publishing accessible course materials Practical advise you can replicate.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
HTML Tags. Objectives Know the commonly used HTML tags Create a simple webpage using the HTML tags that will be discussed.
Headings, Paragraphs, Formatting, Links, Head, CSS, Images
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
 HTML stands for Hyper Text Mark-up Language. The coding language used to create documents for the World Wide Web  HTML is composed of tags. HTML tags.
Website Development with Dreamweaver
1 Committed to Shaping the Next Generation of IT Experts. 02: Enhancing the Web Page HTML.
Introduction To CSS.. HTML Review What is HTML used for? Give some examples of formatting tags in HTML? HTML is the most widely used language on the Web.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga.
PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA.
ODS Statistical Graphics in SAS 9.2 January 17, 2010.
Chapter 8 Introduction to HTML and Applets Fundamentals of Java.
Essentials of HTML Class 4 Instructor: Jeanne Hart
01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.
© 2012 The McGraw-Hill Companies, Inc. All rights reserved. word 2010 Chapter 3 Formatting Documents.
SAS Software Version 8 The Output Delivery System.
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
Page 1 Non-Payroll Cost Transfer Enhancements Last update January 24, 2008 What are the some of the new enhancements of the Non-Payroll Cost Transfer?
HTML Basics BCIS 3680 Enterprise Programming. Web Client/Server Architecture 2  Your browser (the client) requests a Web page from a remote computer.
Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format David Ghan Technical Training Specialist SAS, Canada.
WINKS 7 Tutorial 7 – Advanced Topic: Labels and Formats Permission granted for use for instruction and for personal use. © Alan C. Elliott,
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Office Word 2007 Lab 3 Creating Reports and Tables.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
HTML ( HYPER TEXT MARK UP LANGUAGE ). What is HTML HTML describes the content and format of web pages using tags. Ex. Title Tag: A title It’s the job.
SAS ODS (Output Delivery System) Donald Miller 812 Oswald Tower ;
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Adobe Flash CS4 – Illustrated Unit A: Getting Started with Adobe Flash.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Web Development 101 Presented by John Valance
L. Anne Spencer (c) 2001 Basic Web Design Document, text, & layout formatting tags & attributes.
HTML Basics Computers. What is an HTML file? *HTML is a format that tells a computer how to display a web page. The documents themselves are plain text.
1 Chapter 7: Customizing and Organizing Project Results 7.1 Combining Results 7.2 Updating Results 7.3 Customizing the Output Style (Self-Study)
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
Landscaper 101. Time Code AMC AMCNET HELP!!! Where do you go for help? –Upper right corner has a ? for the online help –This presentation.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
WEEK -1 ACM 262 ACM 262 Course Notes. HTML What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
HTML. INDEX Introduction to HTML Creating Web Pages Commands And Tags Web Page.
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
XP 1 HTML Committed to Shaping the Next Generation of IT Experts. 02: Enhancing the Web Page.
Chapter 5: Enhancing Your Output with ODS
Chapters 5 and 7 supplement
Beautiful PROC CONTENTS Output Using the ODS Excel Destination
Microsoft PowerPoint 2007 – Unit 2
5.00 Apply procedures to organize content by using Dreamweaver. (22%)
Presentation transcript:

Customize your SAS® Output with the Template Procedure: A Beginning Tutorial Carol Gosselin North Carolina State University, Raleigh, NC Joy Munk Smith North Carolina State University, Raleigh, NC

Gosselin and Smith, SESUG Topics Review ODS What are Templates? Working with Predefined Templates Creating your own Style and Table Templates Using your new templates

Gosselin and Smith, SESUG Review ODS Output object: A basic tabular or graphical representation of output. Made up of a data component and a template component. Data component: Collection of raw numbers and strings that make up the table or graph. Template component: A set of instructions that describe how ODS should format and present the raw data.

Gosselin and Smith, SESUG Available Output Destinations Version 8.0 LISTING - classic SAS output HTML – Hyper Text Markup Language OUTPUT - SAS datasets PRINTER – postscript(ps) or printer control language(pcl) Version 8.1 additions: PRINTER – Adobe Acrobat(pdf) RTF - Rich Text Format(rtf)

Gosselin and Smith, SESUG More about Output Destinations Output is sent to all open destinations. LISTING is the only destination open by default. HTML, PRINTER, and RTF, destinations must be closed before the results can be used or viewed. Be sure to include a RUN and QUIT statement before closing a destination or the procedure output may not be sent to the destination.

Gosselin and Smith, SESUG General HTML Example ODS html file= ‘temp.htm’ ; Sascode Run; Quit; ODS html close;

Gosselin and Smith, SESUG General RTF Example ODS rtf file=‘temp.rtf ‘; Sascode Run; Quit; ODS rtf close; Compatible with WORD97 and above. Experimental in 8.0 production in 8.1. (Olinger 2000)

Gosselin and Smith, SESUG General Postscript Example ODS printer file=‘temp1.ps’ ps; Sascode; Run; Quit; ODS printer close; The ps option forces the creation of a postscript file no matter what printer driver you are using.

Gosselin and Smith, SESUG ODS Trace Statement ODS trace on; ODS trace on / listing; ODS trace off; Displays name, label, template, and path of each output object generated. The name displayed can be used to select the output objects to be sent to any open destination.

Gosselin and Smith, SESUG ODS Trace with Proc Freq Ods trace on /listing; Proc freq; Tables ssrace; Run; Ods trace off;

Gosselin and Smith, SESUG ODS Trace with Proc Freq In the output window: Output Added: Name: OneWayFreqs Label: One-Way Frequencies Template: Base.Freq.OneWayFreqs Path: Freq.SRACE.OneWayFreqs Also the proc freq results.

Gosselin and Smith, SESUG ODS Trace with Proc Glm SAS code: ODS trace on / listing; Proc glm; class sresid; Model satv=sresid; Lsmeans sresid; run;

Gosselin and Smith, SESUG ODS Trace with Proc Glm Name Template ClassLevels stat.glm.classlevels Nobs stat.glm.nobs Overallanova stat.glm.overallanova Modelanova (ss1) stat.glm.modelanova Modelanova (ss3) stat.glm.modelanova Means stat.glm.lsmeans

Gosselin and Smith, SESUG Selecting Output Objects OVERALL and destination specific selection and exclusion lists determine which objects are sent to each destination. Modifying Selection Lists Example: ODS html select onewayfreqs; ODS listing select all; (default) ODS listing exclude overallanova; ODS select all; (for OVERALL list)

Gosselin and Smith, SESUG Checking Selection Lists To display selection lists: ODS destination SHOW; For example: ODS html show; This command will print the selection and exclusion lists for the HTML destination and also the overall selection and exclusion lists.

Gosselin and Smith, SESUG Persist Option Selection/Exclusion lists are reset to their default settings at each program step boundary, unless the PERSIST option is specified. Examples: ODS html select onewayfreqs persist; ODS listing select onewayfreqs persist; ODS listing exclude overallanova persist;

Gosselin and Smith, SESUG HTML Output Destination Filename htmldoc "e:\student\ "; ODS html path=htmldoc File='table1.htm' Contents='table1c.htm' Frame='table1f.htm' Style=styles.mystyle Stylesheet= “style.css”(url=“style.css”);

Gosselin and Smith, SESUG Support for CSS Note: In “ODS for Dummies” Olinger states “Use of style sheets will minimize the size of your HTML files. CSS support is experimental in release 8.0 and production in release 8.1”

Gosselin and Smith, SESUG LISTING Destination Traditional SAS output Open by default Default selection list is ALL Examples: ODS listing; ODS listing close; ODS listing select outputobject ; ODS listing exclude outputobject ;

Gosselin and Smith, SESUG ODS References Bryant, Muller, Pass, “ODS, Yes! Odious, No! – An Introduction to the SAS Output Delivery System.” SUGI 25 Proceedings, Olinger, C. R., “ODS for Dummies”, SUGI 25 Proceedings, SAS Institute, The Complete Guide to SAS Output Delivery, Version 8

Gosselin and Smith, SESUG TEMPLATES

Gosselin and Smith, SESUG Table and Style Templates Table and Style templates are the two main types of templates. Table templates provide instructions for formatting a single output object. Style templates provide presentation instructions for all output objects produced. Style templates create a consistent appearance of all SAS output.

Gosselin and Smith, SESUG Table Templates Many table templates are shipped with SAS and they are used for displaying the output objects. Table templates control data column order, column headers and footers, and data formatting. A table template can be bound to an output object in a data step.

Gosselin and Smith, SESUG Style Templates Style Templates: Control the look and feel of the whole SAS job There are 16 styles shipped with SAS 8.0 Sample code: ODS html path= htmldoc file= ‘table1.htm’ style= styles.minimal;

Gosselin and Smith, SESUG Where are Templates Stored? Templates are stored in a new file type called “item stores”. Template stores can have read or update access. For obvious reasons, you should never provide update access to the template store that contains the SAS provided templates.

Gosselin and Smith, SESUG Where are these Template Stores? SAS defines 2 template stores. SASUSER.TEMPLAT(UPDATE) This template store is listed first in the search path and it has update access so user created templates are stored here. SASHELP.TMPLMST(READ) This template store has read only access and it contains the SAS provided templates. Do not provide update access to this file.

Gosselin and Smith, SESUG Providing Access to Template Stores The ODS PATH statement identifies template stores, defines search order, and assigns read/write permissions. Default settings: ODS path sasuser.templat(update) sashelp.tmplmst(read);

Gosselin and Smith, SESUG Default Template Store Path Code: Ods path show; Results in the Log Window with the default settings: The current ODS path list is: 1.SASUSER.TEMPLAT(UPDATE) 2.SASHELP.TMPLMST(READ)

Gosselin and Smith, SESUG Storing Templates User created templates are stored in SASUSER.TEMPLAT because it is the first template store with update access in the path. This can be modified with the PATH statement. Never give write access to SASHELP.TMPLMST

Gosselin and Smith, SESUG SettingTemplate Path ODS path work.temp(update) sashelp.tmplmst(read); Note: You can use the work space and the template store will be temporary. If the template store does not exist it will be created.

Gosselin and Smith, SESUG Viewing Contents of Template Store In the Results Window: Right click on the Results Folder and select Templates Double click on selected Template Store Double click on selected folder Double click on selected template. (or right click and select open, edit, delete, etc.)

Gosselin and Smith, SESUG Template Browser

Gosselin and Smith, SESUG Viewing Template Code: Method 2 To view the template code using SAS code: Proc template; Source styles.minimal; Source styles.default; Run; The template code will be printed in the log window.

Gosselin and Smith, SESUG Why Style Templates? Style templates are used to provide consistent appearance to all SAS output. Typically style templates control aspects like fonts and colors of foreground, background, text. Style templates can also provide instructions for adding graphics to every page.

Gosselin and Smith, SESUG A Simple Style Template Definition Proc Template; Define style styles.mydefault; Style Data / font_size=4; Style Header / font_face=italic; Style Systemtitle / background=white; End; This is a single “style definition” with 3 “style elements” having one “attribute” each.

Gosselin and Smith, SESUG Style Template Syntax Define statement begins the style definition and requires a matching end statement. In the example, the style name is styles.mydefault. Style statements provide attributes for style elements. In the example, the style elements are data, header, and systemtitle.

Gosselin and Smith, SESUG So you want to be an expert? Olinger(1999) states, “There are approximately sixty-five different style attributes that can be specified on a style element. For a complete list, refer to the documentation.” I counted 101 style elements in styles.default. Can’t wait for the certification test on this!

Gosselin and Smith, SESUG Using Your New Style Code: ODS html file=‘table1.htm’ style=styles.mydefault; SAS program statements Run; Quit; HTML close; Explanation: The style= option on the ODS statement is used to select a style template. If the requested template isn’t found the default will be used.

Gosselin and Smith, SESUG Style Element Attributes Font and color are two commonly set style element attributes. These will be covered at an introductory level in these slides and in our examples.

Gosselin and Smith, SESUG Defining Font Attributes A font definition has the following format: (“font-face1”,font-size, keyword list) Font-face: If you specify more than one, the browser uses the first one installed on the system. Font-size: Interpretation of font-size depends on the browser

Gosselin and Smith, SESUG Font Attributes (cont.) Keywords: Font_weight: medium, bold, demi_bold, extra_bold, light Font_style: italic, roman, slant Font_width: normal, compress, extra_compressed, narrow, wide

Gosselin and Smith, SESUG Font Attributes (cont.) Code: Style data / font=(‘Arial, Helvetica’,4,bold italic); Style data / font_face=‘Arial, Helvetic’ font_size=4 font_style=italic font_weight=bold; Explanation: These two statements generate the same results.

Gosselin and Smith, SESUG Color Attributes Some web safe colors (Template Tutorial) Red=#FF0000 Brass=#B5A642 Green=#00FF00 Brown=#A62A2A Blue=#0000FF Bronze=#8C7853 White=#FFFFFF Magenta=#FF00FF Black=# Copper=#B87333 Yellow=#FFFF00 Cadet Blue=#5F9F9F

Gosselin and Smith, SESUG Inheritance Often the easiest way to create a template is to modify an existing template. This is done using inheritance. There are two types of inheritance. 1.“Style definition inheritance” uses the PARENT= statement within a style definition. 2.“Style element inheritance” uses the FROM option on the STYLE statement.

Gosselin and Smith, SESUG Style Definition Inheritance Code: Proc template; Define styles.mydefault; parent=styles.default; When you use parent= all the style elements, attributes, and settings from the parent style are inherited.

Gosselin and Smith, SESUG Style Definition Inheritance When using “style definition inheritance” you can: 1.Modify existing style elements 2.Add new style elements

Gosselin and Smith, SESUG Style Element Inheritance Proc template; Define styles.mydefault; parent=styles.default; Style document / attributes; Style data from document / attributes; Style header from footer / attributes; End;

Gosselin and Smith, SESUG Style Element Inheritance Using “style element inheritance” you can: 1.Inherit style elements from within the current definition. 2.Inherit style elements from the parent when a PARENT= statement is used. Note: attributes are inherited from the parent if the style element doesn’t exist within the current (child) definition.

Gosselin and Smith, SESUG Style Element Inheritance Inherited style elements inherit all the attributes set in the parent. The style elements can be modified and added to.

Gosselin and Smith, SESUG A Sample Table Template Proc template; Edit stat.glm.test as combined.tests; Edit ss; format =7.2; end; Edit ms; format =7.2; end; Run;

Gosselin and Smith, SESUG Bind Template to Output Object Data _null_; set object; File print ods=(template=‘combined.test’); Put _ods_; Run;

Gosselin and Smith, SESUG Test Statement Proc template; Test data=data_set_name; Run; This code will test the most recently created template. Data set variable names must match template column names.

Gosselin and Smith, SESUG Delete Template Proc template; Delete combined.tests; Run; It may be desirable to delete your template if it has the same name as a SAS supplied template. Why? As long as you have a template with the same name as a default template, yours will be used.

Gosselin and Smith, SESUG Storing Your Table Templates Just like with style templates, your table templates will be stored in the first template store that has update access. You can use the work directory. ODS path work.templat(update) sashelp.tmplmst(read); Templates would be stored temporarily. If work.templat doesn’t exist it will be created.

Gosselin and Smith, SESUG Using Your Template: Method 1 With the default path setting: If your table template has the same name as a SAS Institute supplied template and is stored in SASUSER.TEMPLAT, it will be used instead of the Institute supplied template. This is because the template store SASUSER.TEMPLAT is searched before SASHELP.TMPLMST.

Gosselin and Smith, SESUG Using Your Template: Method 2 You can bind your template with the output object in a data step using the FILE statement with the ODS= and TEMPLATE= options.

Gosselin and Smith, SESUG Using Your Template: Method 2 Code: data _null_; Input a b c; file print ods=( template=‘mytemplate’ columns=( col1=a col2=b col3=c ) ); put _ODS_; Note: These 2 methods will be covered in the examples.

Gosselin and Smith, SESUG Proc Template References Heffner(1998) “ODS: The DATA Step Knows”, SUGI 23 Proceedings, Olinger(2000), “Twisty Little Passages, All Alike—ODS Templates Exposed.”, SUGI25 Proceedings. SAS Institute, The Complete Guide to the SAS Output Delivery System, Version 8.

Gosselin and Smith, SESUG Proc Template References (cont.) SAS(2000), “The Template Tutorial”, PDF: lateFAQ/ lateFAQ/ HTML: lateFAQ/Template.html#intro lateFAQ/Template.html#intro

Gosselin and Smith, SESUG Proc Template Tutorial Question and example format Examples mostly modifying styles.default Colors Flyover, tool tips Links margins

Sample Programs Carol Gosselin

Gosselin and Smith, SESUG TABULATE Code Used in Examples PROC TABULATE DATA = b FORMAT = 8.0; FORMAT senrstat $statfmt iof $ioffmt.; CLASS senrstat iof; TABLE iof ALL, SENRSTAT ALL; TITLE 'Enrollment by Residency'; RUN;

Gosselin and Smith, SESUG Data Used in Examples Fictional student data containing the following variables: IOF – Residency (A=In-State, B=Out-of-State, C=International) SENRSTAT – Enrollment Status (1=New, 2=Transfer, 3=Continue, 4=Reenter)

Gosselin and Smith, SESUG Conclusion PROC TEMPLATE is a powerful tool for modifying SAS output. It takes a significant amount of time to master PROC TEMPLATE, but creating simple templates is not hard.

Gosselin and Smith, SESUG Contact Information Carol Gosselin -- Joy Munk Smith -- Examples are available at: –