Writing Data with Excel Libname Engine



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

A Recursive SAS Macro to Automate Importing Multiple Excel Worksheets into SAS Data Sets

AN ANIMATED GUIDE: SENDING SAS FILE TO EXCEL

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

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

ABSTRACT INTRODUCTION SAS AND EXCEL CAPABILITIES SAS AND EXCEL STRUCTURES

Advanced Excel 10/20/2011 1

Mail Merge Creating Mailing Labels 3/23/2011

Excel with SAS and Microsoft Excel

Data Presentation. Paper Using SAS Macros to Create Automated Excel Reports Containing Tables, Charts and Graphs

Word 2010: Mail Merge to with Attachments

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.

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

Microsoft' Excel & Access Integration

Working together with Word, Excel and PowerPoint

Managing very large EXCEL files using the XLS engine John H. Adams, Boehringer Ingelheim Pharmaceutical, Inc., Ridgefield, CT

Exporting Client Information

Moving Data Between Access and Excel

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

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

Methodologies for Converting Microsoft Excel Spreadsheets to SAS datasets

Abstract. For notes detailing the changes in each release, see the MySQL for Excel Release Notes. For legal information, see the Legal Notices.

Using Delphi Data with Excel and Access

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

Different Approaches to Maintaining Excel Reports

Exporting Contact Information

Combining SAS LIBNAME and VBA Macro to Import Excel file in an Intriguing, Efficient way Ajay Gupta, PPD Inc, Morrisville, NC

Same Data Different Attributes: Cloning Issues with Data Sets Brian Varney, Experis Business Analytics, Portage, MI

Overview of sharing and collaborating on Excel data

Formatting Formatting Tables

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

Excel Reports and Macros

Excel Templates. & Quote/Invoice Maker for ACT! Another efficient and affordable ACT! Add-On by V

EXCEL DATA FILE UPLOAD

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

CDW DATA QUALITY INITIATIVE

Online Reporting Tool

Spreadsheet - Introduction

Microsoft Excel 2013 Tutorial

Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

How To Create A Report In Excel

How to Create a Spreadsheet With Updating Stock Prices Version 3, February 2015

PharmaSUG Paper QT26

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

SAS og Excel. Kender du fem forskellige måder at overføre data mellem SAS og Excel? Gert Nissen, seniorkonsulent

SPSS: Getting Started. For Windows

1. Linking among several worksheets in the same workbook 2. Linking data from one workbook to another

Macros allow you to integrate existing Excel reports with a new information system

Microsoft Office Topics per Course

Importing Excel Files Into SAS Using DDE Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

Here is a Trial Balance sample, generated and exported into an Excel spreadsheet, by an accounting software*

Microsoft Courses. Microsoft Office 2007

Preparing Real World Data in Excel Sheets for Statistical Analysis

Preparing a budget template and presenting financial graphs using Excel

How to Make the Most of Excel Spreadsheets

Suite. How to Use GrandMaster Suite. Exporting with ODBC

Financial and operational complexities

Contract Management Submittal Log Import Importing the Submittal Items From MS Excel

Microsoft Office 2010: Access 2010, Excel 2010, Lync 2010 learning assets

Wave Analytics Data Integration

Introduction. This support note provides some information on how MYOB and Excel interact.

Card sort analysis spreadsheet

Move between open workbooks. Display the print menu. Select whole spreadsheet. Microsoft Excel Keyboard Keys. General

Advanced Excel Charts : Tables : Pivots : Macros

As in the example above, a Budget created on the computer typically has:

WHAT S NEW IN MS EXCEL 2013

Creating and Using Forms in SharePoint

EzyScript User Manual

Version: Company: Jabsoft ( Sales and Offers: Model Advisor (htp://

Using SAS to Control and Automate a Multi SAS Program Process. Patrick Halpin November 2008

3 What s New in Excel 2007

Microsoft Excel 2010 Pivot Tables

Microsoft Excel 2010 Linking Worksheets and Workbooks

Microsoft Excel 2007 Mini Skills Overview of Tables

Excel macros made easy

Designed by Jason Wagner, Course Web Programmer, Office of e-learning ZPRELIMINARY INFORMATION... 1 LOADING THE INITIAL REPORT... 1 OUR EXAMPLE...

Importing TSM Data into Microsoft Excel using Microsoft Query

Myridas Catalogue Based Sales User Guide

Using Microsoft Office to Manage Projects

Basic Microsoft Excel 2007

Reporting and Analysis Using Vivid Reports Flex

Working together with Word, Excel and PowerPoint 2013

Microsoft Word 2010 Mail Merge (Level 3)

CJA 20. Automated Billing Program Attorney Training Guide EXCEL BILLING FOR CJA CASES. Page 1

GOOGLE DOCS. 1. Creating an account

Create a new investment form and publish it to a SharePoint 2013 forms library

USING P3 VERSION 3.1 IMPORT AND EXPORT FUNCTIONS WITH THE DBF FILE FORMAT AND EXCEL PAUL E HARRIS EASTWOOD HARRIS

CDOT Monumentation Sheets

Centre for Learning and Academic Development. IT Training. File Management. Windows Vista. Version 1.0

Getting Started Guide

Paper FF-014. Tips for Moving to SAS Enterprise Guide on Unix Patricia Hettinger, Consultant, Oak Brook, IL

Forms Printer User Guide

Introduction. Why Use ODBC? Setting Up an ODBC Data Source. Stat/Math - Getting Started Using ODBC with SAS and SPSS

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

Introduction to Microsoft Access 2003

Microsoft Excel 2007 and Tools for Statistical Analysis David R. Anderson, Dennis J. Sweeney, and Thomas A. Williams

BulkSMS Text Messenger Product Manual

Excel Add-ins Quick Start Guide

Transcription:

Writing Data with Excel Libname Engine Nurefsan (Neffy) Davulcu Advanced Analytics Intern, TransUnion Canada Golden Horseshoe SAS User Group (GHSUG) Burlington, Ontario, Canada MAY 27, 2016

ODS All Functionality PROC EXPORT All Functionality Excel Libname Engine Some Functionality DDE 2015 TransUnion LLC All Rights Reserved 2

What SAS Libname Engine Can Do Create new workbooks Create a new spreadsheet with a named range Write data to an empty existing named range Append data to spreadsheet data or named range data Read data from a pre-existing spreadsheet Read data from a pre-existing named range Delete all the data from a spreadsheet Delete all the data from a named range Do the above without Excel and PC 2015 TransUnion LLC All Rights Reserved 3

What SAS Libname Engine Can t Do Rename spreadsheets within a workbook Delete spreadsheets from a workbook Delete workbooks as a whole Change or apply formatting Delete cells containing formulas Write a formula into a cell 2015 TransUnion LLC All Rights Reserved 4

Big Deal We put some data in Excel Think: How can we use this to automate procedures? How can we use this to avoid repeated manual entry and to avoid manual entry error? How can we use this to create dynamic reports? 2015 TransUnion LLC All Rights Reserved 5

Getting Started SAS 9.0 or later LIBNAME < libref> engine-name <physical-path and filename> <SAS/ACCESS engine-connection-options> <SAS/ACCESS LIBNAME-options> ; < libref> = Give the library a name engine-name = excel *note- this does not need to be specified in most cases, SAS will know from the path name <physical-path and filename> = C:\Users\ndavulc\Documents\workbook.xlsx Options : VER=year 2015 TransUnion LLC All Rights Reserved 6

Getting Started Deassign the library! LIBNAME < libref> clear; 2015 TransUnion LLC All Rights Reserved 7

Getting Started Once the library is assigned, SAS will create the global library icon indicating it s not a library with only SAS datasets. libname workbook excel "C:\Users\ndavulc\Documents\workbook.xlsx"; If the workbook doesn t already exist SAS will create it. 2015 TransUnion LLC All Rights Reserved 8

Excel Named Ranges In Excel we can assign a group of cells a name called named ranges. This is what is used to interact with the libname engine and allows data to be placed anywhere inside a spreadsheet. 2015 TransUnion LLC All Rights Reserved 9

Getting Started The excel libname engine supports many procedures Commonly Used: PROC DATASETS PROC COPY PROC SQL DATA STEP 2015 TransUnion LLC All Rights Reserved 10

Example 1 Create named ranges in SAS and write data

Create named ranges in SAS and write data DATA workbook.class; set sashelp.class; run; Workbook library DATA workbook.retail; set sashelp.retail; run; Named Range Spreadsheet DATA workbook.zipcode; set sashelp.zipcode; run; 2015 TransUnion LLC All Rights Reserved 12

Create named ranges in SAS and write data Now I want to add another column and want to put it in the same class sheet. DATA workbook.class; set sashelp.class; teacher='mrs. Smith'; run; ERROR: The MS Excel table class has been opened for OUTPUT. This table already exists, or there is a name conflict with an existing object. This table will not be replaced. This engine does not support the REPLACE option. 2015 TransUnion LLC All Rights Reserved 13

Create named ranges in SAS and write data We can t overwrite the data! We must first delete the data. PROC DATASETS lib = workbook nolist; delete class; quit; run; 2015 TransUnion LLC All Rights Reserved 14

Create named ranges in SAS and write data We can t overwrite the data! We must first delete the data. PROC DATASETS lib = workbook nolist; delete class; quit; run; *Note that this removes the contents of the Named Range, the assignment of the named Range to a series of cells still exists in the Excel workbook. 2015 TransUnion LLC All Rights Reserved 15

Create named ranges in SAS and write data Now write the data with the extra teacher column. DATA workbook.class; set sashelp.class; teacher='mrs. Smith'; run; Note that the contents of this dataset will not fit in the previous existing class named range. The named range will be expanded in Excel to fit the new data given the surrounding area is empty. 2015 TransUnion LLC All Rights Reserved 16

Create named ranges in SAS and write data Don t forget to de assign the library when you re done! libname workbook clear; 2015 TransUnion LLC All Rights Reserved 17

Example 2 Write data to a premade Excel Template

Write data to a premade Excel Template I have a Simple Budget Worksheet where I have already defined three named ranges. 2015 TransUnion LLC All Rights Reserved 19

Write data to a premade Excel Template Assign a library to the simple budget worksheet exactly as before: libname workbook excel "C:\Users\ndavulc\Documents\simple_budget.xlsx"; 2015 TransUnion LLC All Rights Reserved 20

Write data to a premade Excel Template PROC DATASETS lib = workbook nolist; delete income expenses savings; quit; run; PROC SQL; create table workbook.income as select * from income; create table workbook.expenses as select * from expenses; create table workbook.savings as select * from savings; quit; libname workbook clear; 2015 TransUnion LLC All Rights Reserved 21

Write data to a premade Excel Template Problem #1: We can only map one data cell to one Excel cell The merged cells will not be accounted for. Fix #1a: Format the spreadsheet accordingly. 2015 TransUnion LLC All Rights Reserved 22

Write data to a premade Excel Template Problem #2: SAS will write the variable names. 2015 TransUnion LLC All Rights Reserved 23

Write data to a premade Excel Template Problem #2: SAS will write the variable names. Fix #2a: Account for this in the named range so that the headings in the spreadsheet are populated according to the variable names in SAS. 2015 TransUnion LLC All Rights Reserved 24

Write data to a premade Excel Template Problem #2: SAS will write the variable names. Fix #2b: Use Hidden cells. 2015 TransUnion LLC All Rights Reserved 25

Write data to a premade Excel Template Let s say we had 30 expenses listed in our SAS dataset and tried to write to Excel. ERROR: Error attempting to CREATE a DBMS table. ERROR: Execute: Too many fields defined.. WARNING: File deletion failed for WORKBOOK.expenses.data Remember that we can t delete cells containing formulas. 2015 TransUnion LLC All Rights Reserved 26

Write data to a premade Excel Template Problem #3: Unlike when we exported data in the first example, we are more constrained to the size of the named range that we have defined. 2015 TransUnion LLC All Rights Reserved 27

Wrap Up Utilize Excel s visual capabilities and SAS analytic capabilities by separating the visual and data aspects Increase efficiency by reducing manual entry and repetition 2015 TransUnion LLC All Rights Reserved 28

Contact Information Nurefsan (Neffy) Davulcu Advanced Analytics Intern, TransUnion Canada Work phone: 905-340-1000 Ext 2049 Work email: ndavulc@transunion.com McMaster University, Honours Math & Stats (Level 4, Co-op) Personal Cell: 289-689-7383 School Email: davulcn@mcmaster.ca

References Choate, Paul A and Martell, Carol A. De-Mystifying the SAS LIBNAME Engine in Microsoft Excel: A Practical Guide Accessed May 25, 2016. http://www2.sas.com/proceedings/sugi31/024-31.pdf. Heaton, Ed. So, Your Data are in Excel! Accessed May 25, 2016. http://www2.sas.com/proceedings/sugi31/020-31.pdf. Droogendyk, Harry. Customized Excel Output Using the Excel Libname Accessed May 25, 2016. http://www.stratia.ca/papers/excel_libname.pdf. Libname Statement Syntax SAS Institute. Accessed May 25, 2016. http://support.sas.com/documentation/cdl/en/acpcref/63181/html/default/viewer. htm#n1wvmggexroxgyn17rp61jml3cvn.htm.