SAS to Excel with ExcelXP Tagset Mahipal Vanam, Kiran Karidi and Sridhar Dodlapati



Similar documents
Tips and Tricks for Creating Multi-Sheet Microsoft Excel Workbooks the Easy Way with SAS. Vincent DelGobbo, SAS Institute Inc.

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA

Creating Multi-Sheet Microsoft Excel Workbooks with SAS : The Basics and Beyond. Part 2

Embedded Special Characters Kiran Karidi, Mahipal Vanam, and Sridhar Dodlapati

Integrating SAS and Excel: an Overview and Comparison of Three Methods for Using SAS to Create and Access Data in Excel

Create an Excel report using SAS : A comparison of the different techniques

Report Customization Using PROC REPORT Procedure Shruthi Amruthnath, EPITEC, INC., Southfield, MI

Printable Spreadsheets Made Easy: Utilizing the SAS Excel XP Tagset Rick Andrews, Office of the Actuary, CMS, Baltimore, MD

Using SAS Output Delivery System (ODS) Markup to Generate Custom PivotTable and PivotChart Reports Chevell Parker, SAS Institute

ABSTRACT INTRODUCTION SAS AND EXCEL CAPABILITIES SAS AND EXCEL STRUCTURES

Customized Excel Output Using the Excel Libname Harry Droogendyk, Stratia Consulting Inc., Lynden, ON

It s not the Yellow Brick Road but the SAS PC FILES SERVER will take you Down the LIBNAME PATH= to Using the 64-Bit Excel Workbooks.

Preserving Line Breaks When Exporting to Excel Nelson Lee, Genentech, South San Francisco, CA

THE HELLO WORLD PROJECT

Let SAS Modify Your Excel File Nelson Lee, Genentech, South San Francisco, CA

Secrets from a SAS Technical Support Guy: Combining the Power of the SAS Output Delivery System with Microsoft Excel Worksheets

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Methodologies for Converting Microsoft Excel Spreadsheets to SAS datasets

Search help. More on Office.com: images templates. Here are some basic tasks that you can do in Microsoft Excel 2010.

The first thing to do is choose if you are creating a mail merge for printing or an merge for distribution over .

TheFinancialEdge. Reports Guide for Accounts Receivable

Two new DB2 Web Query options expand Microsoft integration As printed in the September 2009 edition of the IBM Systems Magazine

Excel with SAS and Microsoft Excel

Microsoft Excel 2013 Tutorial

Microsoft Migrating to Word 2010 from Word 2003

TheFinancialEdge. Reports Guide for General Ledger

Basic Excel Handbook

To reuse a template that you ve recently used, click Recent Templates, click the template that you want, and then click Create.

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

Microsoft Excel Understanding the Basics

Advanced Excel 10/20/2011 1

Introduction to Microsoft Excel 2010

Microsoft Word Quick Reference Guide. Union Institute & University

Microsoft Excel Training - Course Topic Selections

Microsoft Excel 2010 Tutorial

ABSTRACT INTRODUCTION CLINICAL PROJECT TRACKER OF SAS TASKS. Paper PH

Release 2.1 of SAS Add-In for Microsoft Office Bringing Microsoft PowerPoint into the Mix ABSTRACT INTRODUCTION Data Access

Microsoft Excel 2013: Macro to apply Custom Margins, Titles, Gridlines, Autofit Width & Add Macro to Quick Access Toolbar & How to Delete a Macro.

THE SAS OUTPUT DELIVERY SYSTEM: BOLDLY TAKE YOUR WEB PAGES WHERE THEY HAVE NEVER GONE BEFORE! CHEVELL PARKER, SAS INSTITUTE INC.

Excel 2010: Create your first spreadsheet

Excel 2007: Basics Learning Guide

Excel 2003 Tutorial I

Producing Structured Clinical Trial Reports Using SAS: A Company Solution

Q&As: Microsoft Excel 2013: Chapter 2

Secure Website and Reader Application User Guide

Creating Raw Data Files Using SAS. Transcript

Inquisite Reporting Plug-In for Microsoft Office. Version 7.5. Getting Started

Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC

Excel 2003 A Beginners Guide

Blackbaud StudentInformationSystem. Reports Guide for Admissions Office

Legal Notes. Regarding Trademarks. Model supported by the KX printer driver KYOCERA MITA Corporation

Information Server Documentation SIMATIC. Information Server V8.0 Update 1 Information Server Documentation. Introduction 1. Web application basics 2

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

PharmaSUG Paper QT26

Microsoft Word 2010 Tutorial

Creating an Excel Database for a Mail Merge on a PC. Excel Spreadsheet Mail Merge. 0 of 8 Mail merge (PC)

Utilizing SAS for Complete Report Automation Brent D. Westra, Mayo Clinic, Rochester, MN

Annual Leave Management Excel Template User Guide

SAS ODS. Greg Jenkins

Course Descriptions for Focused Learning Classes

Data Analysis with Microsoft Excel 2003

Directions to Print from WorkFlows:

dopdf dopdf User Manual dopdf does PDF. For free. Copyright 2015 Softland

Excel 2007 A Beginners Guide

Microsoft Excel 2007 Level 2

Excel 2003 Tutorials - Video File Attributes

Application Note. Building a Website Using Dreamweaver without Programming. Nan Xia. MSU ECE 480 Team 5

Creating Word Tables using PROC REPORT and ODS RTF

Excel 2007 Basic knowledge

Microsoft Office Topics per Course

Chapter 1 Kingsoft Office for Android: A Close Look. Compatible with Microsoft Office: With Kingsoft Office for Android, users are allowed to create,

Aspose.Cells Product Family

ENHANCING SAS OUTPUT WITH OUTPUT DELIVERY SYSTEM (ODS)

ODS for PRINT, REPORT and TABULATE

IBM Unica emessage Version 8 Release 6 February 13, User's Guide

Microsoft Word 2010 Prepared by Computing Services at the Eastman School of Music July 2010

How To Create A Report On A Pc Or Macbook

Styles, Tables of Contents, and Tables of Authorities in Microsoft Word 2010

SPSS for Windows importing and exporting data

How To Use Cleanersmate Software On A Pc Or Mac Or Macbook Or Macintosh (For Pc Or Pc) With A Computer Or Mac (For Mac) With An Ipa Or Mac Xp (For A Mac) On A Computer With

Intro to Mail Merge. Contents: David Diskin for the University of the Pacific Center for Professional and Continuing Education. Word Mail Merge Wizard

Microsoft Office Word 2010: Level 1

Excel 2007 Tutorials - Video File Attributes

Anoto pendocuments. User s Guide

TIBCO Spotfire Automation Services 6.5. User s Manual

SAS Add in to MS Office A Tutorial Angela Hall, Zencos Consulting, Cary, NC

Flat Pack Data: Converting and ZIPping SAS Data for Delivery

Password Memory 6 User s Guide

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

Enhanced Formatting and Document Management. Word Unit 3 Module 3. Diocese of St. Petersburg Office of Training Training@dosp.

Creating trouble-free numbering in Microsoft Word

ECDL / ICDL Word Processing Syllabus Version 5.0

A simple tool to catalogue statistical outputs developed for submission by linking two in-house systems experience from a submission project

Web Portal User Guide. Version 6.0

Transcription:

PharmaSUG2010 - Paper CC22 SAS to Excel with ExcelXP Tagset Mahipal Vanam, Kiran Karidi and Sridhar Dodlapati ABSTRACT Creating XML based excel files is a very convenient and powerful feature of SAS 9 or later version. This paper provides a brief overview of the ODS Tagsets.ExcelXP destination to generate XML output that conform to the Microsoft XML Spreadsheet Specifications and can be opened with Microsoft Excel 2002 (also known as Excel XP) or later version. And also, by using ExcelXP tagsets we can create multi-sheet Microsoft Excel workbooks very quickly and easily. INTRODUCTION The ODS ExcelXP Tagset/Destination generates output in Microsoft s SpreadsheetML XML format, and is extremely flexible with many options. It is used specifically for importing data into Excel (2002 or later version). By default, the titles and footnotes in the SAS code will be part of spreadsheet header and footer, i.e., titles and footnotes are only seen either in print preview or when the document is printed. Also by default, the printing orientation will be in 'Portrait', but can be changed to landscape. The tagset options control the appearance and functionality of the Excel workbook. Many of these tagset options are simply tied straight into existing Excel options or features. The code used in this paper should be run in SAS 9.1 or later release, and the generated XML file should be opened with Microsoft Excel 2002 or later version. ExcelXP tagset was experimental in SAS 8.2. This technique doesn t need to have license for SAS/ACCESS to PC files software, as it just needs SAS Base and works on any platform on which SAS software is installed. The ExcelXP tagset offers complete control over worksheets in a workbook, such as Creating multiple worksheets within a workbook very easily. Controlling worksheet name within a workbook. Incorporating titles in the worksheet or in the print preview. Adjusting the column and row heights by using options. By default they are automatically calculated based on the font size and data. Controlling a multitude of printing options for each worksheet, including column and row repeat, scale, and orientation. SYNTAX The syntax needed to generate XML output, which is compatible with versions 2002 and later of Microsoft Excel: ODS Tagsets.ExcelXP file='file-name.xml' style=stylename options(option-name1='value1' option-name2='value2'...); *SAS code which produces output starts here; *SAS code ends here; ODS Tagsets.ExcelXP CLOSE; *must close Tagsets.ExcelXP here*; file='file-name.xml': specifies your external file that contains the XML output. We can just write the file name to save it in a default directory or provide full path including file name to save it in a different directory. style=stylename: Optional. If we don't specify style option, "default" style will be used. 1

options (option-name1='value1' option-name2='value2'...): Optional. If we don't specify anything default options will be used. ODS Tagsets.ExcelXP CLOSE: Statement closes and releases the XML file so that it can be opened with Excel. EXAMPLES Example 1: Basic code with all default settings: ods Tagsets.ExcelXP file='c:\temp\test.xml'; title 'Listing of Class data'; The figure below, generated from above code, shows the default settings of the ExcelXP tagset, including the default style, the default title settings, and the default sheet naming conventions. i.e. the default style is the gray background and the blue column headings. The default title settings place the titles and footnotes in the header and footer, respectively, which will show in print preview or when you print the document. The default sheet name is Table n Data Set dataset name, as shown in below figure. TAGSETS.EXCELXP OPTIONS As mentioned earlier, the ExcelXP tagset supports several options that control both the appearance and functionality of the Excel workbook. Many of these tagset options are simply tied straight into existing Excel options or features. Tagset options are specified on the ODS statement using the "options" keyword: ods Tagsets.ExcelXP options(option-name1='value1' option-name2='value2'...); To see the ExcelXP options/documentation within the SAS log, submit the following SAS code: ods tagsets.excelxp file="test.xml" options(doc="help"); ods tagsets.excelxp close; By submitting the above code, the help text in SAS log shows options including, orientation, frozen_headers, frozen_rowheaders, autofilter, autofilter_table, default_column_widths, sheet_interval, sheet_name, sheet_label, and auto_subtotals, etc... It is important to note that tagset options remain in effect until they are either turned off or set to another value. Since multiple ODS statements are allowed, it is good practice, in terms of functionality and code readability, to explicitly reset tagset options to their default values when you are finished using them. 2

As mentioned earlier, by default, SAS titles and footnotes appear as Excel print headers and print footers, which are displayed only when the Excel document is printed/previewed. To include the titles and footnotes in the worksheets, use the EMBEDDED_TITLES and EMBEDDED_FOOTNOTES options: ods tagsets.excelxp options(embedded_titles='yes' embedded_footnotes='yes'); Example 2: Option set to orientation as landscape: ods Tagsets.ExcelXP file='c:\temp\test1.xml' options(orientation='landscape'); Example 3: Controlling worksheet names: ODS generates a unique name for each worksheet, as required by Microsoft Excel. There are, however, several tagset options that you can use to alter the names of the worksheets. The Sheet_Name option is used to explicitly set the worksheet name. ods Tagsets.ExcelXP file='c:\temp\test2.xml' options(sheet_name='class'); 3

Example 4: Creating multiple worksheets and controlling their names: When you create multiple outputs, each table will be placed in its own worksheet within a workbook. Worksheet names can be up to 31 characters long. This name will be used in combination with a worksheet counter to create a unique name. ods Tagsets.ExcelXP file='c:\temp\test3.xml' options(sheet_name='temp'); proc print data=sashelp.manage; Example 5: Assigning each worksheet a unique name, instead of using one name and counter attached to it for subsequent worksheets: ods Tagsets.ExcelXP file='c:\temp\test4.xml' options(sheet_name='class Data'); proc print data=class; 4

ods tagsets.excelxp options(sheet_name='demog Data'); proc print data=demog; Example 6: Controlling Auto Filter: ods Tagsets.ExcelXP file='temp\test5.xml' options(sheet_name='demog data' AutoFilter='All'); proc print data=demog noobs; var subjid Sex Age Height Weight; Example 7: Using STYLE option: The STYLE option controls the appearance of the output, such as the font and color scheme etc. ods Tagsets.ExcelXP file='temp\test6.xml' STYLE=sansPrinter; proc print data=demog noobs; 5

var subjid Sex Age Height Weight; Although not an ExcelXP option, the ODS option STYLE can be used with the ExcelXP tagset. Styles can be customized or created using PROC TEMPLATE, but SAS has many styles built-in for use. To see the names of available built-in styles, submit the following SAS code: proc template; list styles; quit; TAGSETS Tagsets are kind of templates and are defined using Template Procedure. To get a list of SAS supplied tagsets submit the following code: proc template; list tagsets; quit; To see the source for a tagset definition, specify the two-level name of the tagset within Proc Template. The code will then appear in the SAS log. For example to see source for ExcelXP tagset, submit the following code: proc template ; source tagsets.excelxp; quit; Since the ExcelXP tagset is still evolving, there are some limitations and hence its functionality may be changed in future. It is recommended that the user always download the latest ExcelXP tagset from the SAS ODS MARKUP page. The most up-to-date tagsets are available for download from the ODS Markup Resources site at http://support.sas.com/rnd/base/topics/odsmarkup/ In this paper, we used the ExcelXP Tagset version (SAS 9.1.3, v1.28, 08/29/2005). Quick Reference for the TAGSETS.EXCELXP Tagset can also be found in http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_help.html 6

XML XML is a technology that is designed for managing and sharing structured data in a human-readable text file. XML follows industry-standard guidelines and can be processed by a variety of databases and applications. Using XML, application designers can create their own customized tags, data structures, and schemas. In short, XML greatly eases the definition, transmission, validation, and interpretation of data between databases, applications, and organizations. XML SUPPORT IN EXCEL 2002 OR LATER Microsoft s Excel 2002 (also known as Excel XP) or later version supports importing XML documents as well as saving workbooks as XML files. To save a workbook in XML format, select File Save As, and then choose the "XML Spreadsheet" format. Your entire workbook is saved as a single XML file, which can then be imported into one or more SAS datasets (each worksheet is imported into a separate SAS dataset). XML files which conform to the Microsoft XML Spreadsheet Specification can be opened by Excel 2002 or later version, the ODS ExcelXP tagset creates such files. Thus, to import your SAS output that was generated using the ODS ExcelXP tagset into Excel, just open the XML file with Excel. Excel does not support graphics in XML files. REFERENCES http://support.sas.com/rnd/base/ods/odsmarkup/ http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_help.html http://office.microsoft.com/en-us/excel/ha102063961033.aspx V DelGobbo, "Creating Multi-Sheet Excel Workbooks they Easy Way with SAS". http://www2.sas.com/proceedings/forum2007/120-2007.pdf E Gebhart, "The Beginners Guide to ODS MARKUP: Don't Panic!. http://support.sas.com/rnd/base/ods/odsmarkup/p236-31.pdf CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Mahipal Vanam (Mahipal.Vanam@EMDSerono.com, Mahipal.V@gmail.com) Kiran Karidi (Kiran.Karidi@Novartis.com, KaridiKiran@yahoo.com) Sridhar Dodlapati (Sridhar.Dodlapati@frx.com, Sridhardpt@yahoo.com) SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 7