M AKE E ASY S TYLE T EMPLATES U SING SAS M ACRO Barbara Harlan.

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

Use Tables for Layout Control Day 7. You will learn to: Understand Tables Create a Simple Table Modify Your Tables Appearance Create Page Layouts with.
Chapter 3 – Web Design Tables & Page Layout
Excel Tutorial 2: Formatting Workbook Text and Data
Microsoft Word 2013 An Overview. Your Environment Quick Access Toolbar Customizable toolbar for one-click shortcuts Tabs Backstage View Tools located.
THE PROFESSIONAL APPROACH SERIES © 2008 The McGraw-Hill Companies, Inc. All rights reserved. 1 Lesson Objectives Lesson 5 objectives Use a template to.
Understanding Microsoft Excel
Tutorial 12: Enhancing Excel with Visual Basic for Applications
EXCEL Spreadsheet Basics
Copyright 2003 Peter McDevitt 1 Microsoft Excel 2002 Lecture 3 – A Professional Looking Worksheet.
How to Create a Custom Style Sonia Extremera / Antonio Nieto / Javier Gómez PhUSE Annual Conference, 9th-12th Oct 2011, Brighton UK.
® Microsoft Office 2010 Excel Tutorial 2: Formatting a Workbook.
1 BIL101, Introduction to Computers and Information Systems Chapter 7 Microsoft Word This chapter is based on the Turkish documents written by Fahrettin.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 3 1 Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional- Looking.
CIS101 Introduction to Computing Week 07. Agenda Your questions Resume project Review Project Two HTML Project Three This week online Next class.
Using HTML Tables.
COMPREHENSIVE Excel Tutorial 2 Formatting a Workbook.
HTML Overview for Proofreading. HTML layouts are divided into sections, and created in tables separating the images & content sections.
Review HTML  What is HTML?  HTML is a language for describing web pages.  HTML stands for Hyper Text Markup Language  HTML is not a programming language,
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
Software Apps. Word, PowerPoint, Excel, Access Mr. Miller.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Excel Part 2 Formatting a Workbook. XP Objectives Format text, numbers, and dates Change font colors and fill colors Merge a range into a single cell.
SAS PROC REPORT PROC TABULATE
Web Technologies Website Development Trade & Industrial Education
Using a Spreadsheet Chapter 5.
Website Development with Dreamweaver
Using a Template to Create a Resume and Sharing a Finished Document
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional-Looking Worksheet.
The switch from Microsoft Office 2003 to 2007 Microsoft Word Microsoft Excel Microsoft PowerPoint.
Excel Ch 6 Review.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
PROC TEMPLATE: The Basics Lauren Haworth Genentech, Inc. South San Francisco, CA.
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.
Using the new Version 8 Template Procedure for Complete Control of SAS Output Style and Format David Ghan Technical Training Specialist SAS, Canada.
Publishing to PDF SNUG Quarter 2. Overview n What is PDF? n Why use PDF? n Creating PDF files with SAS Software n Issues n Advanced PDF files with SAS.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Office Word 2007 Lab 3 Creating Reports and Tables.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
SAS ODS (Output Delivery System) Donald Miller 812 Oswald Tower ;
1 CA201 Word Application Arranging and Printing Documents Week # 4 By Tariq Ibn Aziz Dammam Community college.
Microsoft® Excel Key and format dates and times. 1 Use Date & Time functions. 2 Use date and time arithmetic. 3 Use the IF function. 4 Create.
Lesson 1 – Microsoft Excel * The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Microsoft Excel Spreadsheet Software
Microsoft Office Illustrated Introductory, Second Edition with Excel 2003 Getting Started.
Understanding Microsoft Excel Lesson 1 – Microsoft Excel 2013.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
Microsoft ® Excel ® 2013 Enhanced Excel Tutorial 2: Formatting Workbook Text and Data.
Chapter 4 Crystal Report Presenter: PEN PHIROM (MscIT) Phone:
ODS TAGSETS - a Powerful Reporting Method Derek. 2 Agenda Understanding the tagset How to use tagsets Conclusion.
1 SAS ® ODS Technology for Today’s Decision Makers Sunil Gupta Quintiles.
1 Word Processing Intermediate Using Microsoft Office 2000.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.
A MORE COMPLETE ODS REPORT. What we’re going to talk about…  Creating a title page  Creating an introduction page  Creating long-form text descriptions.
Understanding Microsoft Excel
Understanding Microsoft Excel
Understanding Microsoft Excel
Using ODS Excel Migrating from DDE to ODS
Tutorial 2: Formatting a Workbook
Objectives Format text, numbers, and dates
Understanding Microsoft Excel
Microsoft Excel 101.
Understanding Microsoft Excel
Presentation transcript:

M AKE E ASY S TYLE T EMPLATES U SING SAS M ACRO Barbara Harlan

A BOUT THE PAPER This paper’s primary purpose is to show you how to create a style template so that you can output all of your SAS tables into Word without having to format in Word Why not just format in Word? It saves time if you are output lots of tables that will need the same formatting (like the Dashboards). Also if the table needs to be twirked later (like editing an observation) you can quickly output the new table without having to redo all the formatting.

O UTPUTTING SAS T ABLES Barbara Harlan

O UTPUT D ELIVERY S YSTEM (ODS) LISTINGproduces traditional SAS output HTMLproduces output for online viewing MARKUPproduces output for markup language tagsets (like Excel) OUTPUTproduces SAS output datasets PRINTERproduces presentation-ready printed reports RTFproduces output suitable for Microsoft Word reports

ODS C ODE Syntax: ODS destination_name FILE=“filename”; * Your SAS procedure code here; ODS destination_name CLOSE; Example: ODS RTF FILE= “myoutput.rtf” ; PROC PRINT DATA=sashelp.class; RUN; ODS RTF CLOSE; Note: You must close the ODS for the file to be created Be sure to attach the appropriate extension on the end of the filename (i.e. “filename.rtf for an rtf destination”)

S TYLE O PTION By default, ODS uses the default SAS style template for the selected destination. By using the STYLE= setting you can switch to a different SAS supplied style or your custom style. Example: ODS RTF FILE= “myoutput.rtf” STYLE=brick; PROC PRINT DATA=sashelp.class; RUN; ODS RTF CLOSE;

ObsNameSexAgeHeightWeight 1AlfredM AliceF BarbaraF Sample of the default style for RTF output: Sample of the “Brick” style supplied by SAS: ObsNameSexAgeHeightWeight 1 AlfredM AliceF BarbaraF

W HAT YOU CAN DO WITH ODS AND E XCEL

R EQUIREMENTS Base SAS Software, or later, any operating system recent version of the ExcelXP ODS tagset xcltags.tpl Microsoft Excel 2002 (aka Excel XP) or later

B ASIC C ODE ods tagsets.ExcelXP file='MyWorkbook.xml' style=sansPrinter options( ); * Your SAS procedure code here; ods tagsets.ExcelXP close; Note Only the PRINT, REPORT, and TABULATE procedures support ODS style overrides

O PTIONS - T ITLES EMBEDDED_FOOTNOTESdefault value: ‘No’ EMBEDDED_TITLESvalues: ‘Yes’,‘No’ By default, the titles and footnotes of your output will not be displayed on the Excel worksheet. To display them, turn on the EMBEDDED_FOOTNOTES, EMBEDDED_TITLES options.

O PTIONS - P RINT H EADERS PRINT_HEADERvalue: character string PRINT_FOOTER PRINT_FOOTER=“&C&A&RPage &P of &N”; SheetnamePage 1 of 12

Values can be ‘None’ ‘All’ or a range ODS tagsets.ExcelXP FILE="C:\Documents and Settings\Barbie\Desktop\TEMPLATE MACRO\AutofilterEx.xls" STYLE=XLsansprinter OPTIONS(autofilter="All" absolute_column_width='10'); PROC PRINT DATA=sasuser.autofilter NOOBS LABEL; VAR surveyid fixed_mobile sitetype org siteid pat_volume epms epms_product emr q10_emr_product q10_emr_date; LABEL pat_volume='Patient Volume' epms_product='EPMS Product' q10_emr_product='EMR Product' q10_emr_date='EMR Date Acquired'; RUN; ODS tagsets.ExcelXP CLOSE; O PTIONS - A UTOFILTER

O PTIONS - B Y G ROUP P ROCESSING ODS tagsets.ExcelXP FILE="C:\Documents and Settings\Barbie\Desktop\TEMPLATE MACRO\AutofilterEx.xls" STYLE=XLsansprinter OPTIONS(suppress_bylines=‘yes’ sheet_interval=‘bygroup’ sheet_label=‘ ‘ autofit_height=‘yes’; PROC PRINT DATA=dash.pat_enc NOOBS LABEL; BY org; PAGEBY org; VAR period; VAR PC_Patients; VAR PC_Encounters; VAR BH_Patients; VAR BH_Encounters; VAR PC_and_BH_Patients; RUN; ODS tagsets.ExcelXP CLOSE;

F ROM SAS TO W ORD AND NOT A DROP OF FORMATTING

T EMPLATES A template is a stored collection of formatting instructions that control the individual components of a report. There are over a 100 individual components or style elements that control your report. ODS has two main types of templates: style templates and table templates. Style templates provide output formatting for the entire SAS program while table templates are for selected procedure output within a program.

Style templates provide specifications such as: Fonts Colors Borders Margins Backgrounds Cell spacing and padding

T EMPLATE B ROWSER To explore templates, open the Template Browser by selecting VIEW →TEMPLATES from the Toolbar ( Note: The Results window must be selected ). The Template Browser window will be displayed.

A NATOMY OF A S TYLE T EMPLATE C ODE

T HE M ACRO The complete macro contains two programs: The first, Custom Style Macro, contains the style template and attribute references macros. The second program, Custom Style Macro CALL, has the call statements for these macros. There is a %include statement in the second program that will run the Custom Style Macro program when Custom Style Macro CALL is run.

A little about macros… Macros are programs that allow you to write dynamic code. %MACRO macro_name ( ); * Your SAS procedure code here; %MEND; %macro_name ( ); Call Statement It’s dynamic since you can change the values of the parameters without retyping the whole program.

C USTOM S TYLE M ACRO

C USTOM S TYLE M ACRO CALL The call statement uses lots of notes throughout to make it clear which attributes you are changing. Parameters are divided into sections, such as TITLE or COLUMN HEADER, based on what attributes they affect. Above each parameter, there is a note that describes what the parameter controls in the output. In order to change an attribute’s value, you simply replace the default value written in the call statement with the value you would like the attribute to have.

%CUSTOM_STYLE_TEMPLATE ( /****************** NAME OF STYLE TEMPLATE ***********************/ STYLENAME=Superbowl, /****************** OUTPUT SETTINGS *******************************/ /****************** TITLE ***************************************/ /*Text size for titles from TITLE statement*/ TITLESIZE= 12pt, /****************** FOOTNOTE ************************************/ /*Text size for footers from FOOTNOTE statement*/ FOOTSIZE= 10pt, /*Font weight for footers from FOOTNOTE statement*/ FOOTWEIGHT= Medium, /****************** COLUMN HEADERS ******************************/ /*Text size for COLUMN and ROW headers in table*/ HSIZE= 11pt, /*Vertical justification of COLUMN and ROW headers in table*/ VHJUST= bottom, /*Background color for COLUMN headers in table*/ CHBACKGROUND= palegoldenrod, /****************** ROW HEADERS *********************************/ /*Background color for ROW headers in table*/ RHBACKGROUND= palegoldenrod, /****************** DATA CELLS ***********************************/ /*Justification of DATA in cells*/ DATAJUST= right, /*Vertical justification of DATA in cells*/ VDATAJUST= bottom, /****************** TABLE APPEARANCE ******************************/ /*Padding between cell border and cell contents in TABLE*/ CELLPADDING= 5pt, /*Type of rules (lines) that go inside TABLE (see %frames_and_rules for a list of values)*/ RULES= rows, /*Width of FRAMES (RULE width is dictated by cellspacing)*/ BORDERWIDTH= 1.5pt ); QUIT;

A PPLYING Y OUR C USTOM S TYLE T EMPLATE PROC FORMAT; VALUEyesno 1='Yes‘ 0='No‘.='Missing'; VALUE$OrgType 'PC'='Primary Care‘ 'BH'='Behavioral Health'; PICTUREpctfmt (default=7) low-high='009.9%'; RUN; ODS RTF FILE="C:\Documents and Settings\Barbie\Desktop\TEMPLATE MACRO\TemplateEx.rtf" STYLE=Superbowl STARTPAGE=yes BODYTITLE; TITLE 'Table 3: Availability of Electronic Practice Management Systems (EPMS)'; FOOTNOTE 'Patient volumes over 18 months (Sept 2007 to March 2009)'; FOOTNOTE2 'Volume data not available for 3 sites'; PROC TABULATE DATA=sasuser.autofilter FORMAT=comma7.; CLASS sitetype epms emr; VAR pat_volume; TABLE sitetype=' ' all='All Sites'*{style={font_weight=bold}},epms*(n rowpctn*F=pctfmt7. pat_volume='Volume') all='Total'*(n rowpctn*F=pctfmt7.) / misstext='0' BOX={LABEL="Organization Type"}; KEYLABEL n='N' sum=' ' rowpctn='%'; FORMAT sitetype $orgtype. epms emr yesno.; RUN; ODS RTF CLOSE;

N OTE Will not affect graphs! To customize your graphs you must use GOPTIONS SAS 9.2 now has ways you can make “graph templates”… Future paper? ;) Graphs that output to Word will output as pictures- you will not be able to edit them!

W HERE DO I GET THIS MAGICAL MACRO ? The code is attached to the end of my paper It is also available on my new website It will be placed in a public folder on the L drive