Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

CC SQL Utilities.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Introduction to SAS Programming Christina L. Ughrin Statistical Software Consulting Some notes pulled from SAS Programming I: Essentials Training.
Statistics in Science  Introducing SAS ® software Acknowlegements to David Williams Caroline Brophy.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
1 Creating and Tweaking Data HRP223 – 2010 October 24, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Basic And Advanced SAS Programming
Copyright  Oracle Corporation, All rights reserved. 4 Creating Functions.
Jeremy W. Poling B&W Y-12 L.L.C. Can’t Decide Whether to Use a DATA Step or PROC SQL? You Can Have It Both Ways with the SQL Function!
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Into to SAS ®. 2 List the components of a SAS program. Open an existing SAS program and run it. Objectives.
Creating SAS® Data Sets
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
The New SAS Engine For CRSP   Benefits of using SAS engine for CRSP   Setting up the interface between SAS and CRSP   Examples of use   Performance.
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.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 10:Processing Macro Variables at Execution Time 1 STAT 541 © Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
ASP.NET Programming with C# and SQL Server First Edition
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Introduction to SAS. What is SAS? SAS originally stood for “Statistical Analysis System”. SAS is a computer software system that provides all the tools.
SAS Options – Versatile Players in the Game of SAS Denise Poll, SAS Institute Inc.
SAS ® PROC SQL or Vanilla Flavor Cecilia Mauldin January
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
PowerBuilder Online Courses - by Prasad Bodepudi
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
Bringing Data into SAS From Menu: –File –Import Data –Spreadsheet example first Pick file by browsing Select Library and Member (we will talk about this.
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
A SAS User's Guide to Storage Management Allan Page Senior Marketing Analyst Canadian Tire Financial Services.
Files Tutor: You will need ….
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
TASS Meeting Setting GuessingRows when Importing Excel Files September 19th, 2008 Setting GuessingRows when importing Excel Files Dr. Arthur Tabachneck,
HRP Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
Microsoft ® Excel ® 2013 Enhanced Excel Tutorial 3 Calculating Data with Formulas and Functions.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
 CONACT UC:  Magnific training   
Copyright © 2008, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
SAS Certification Prep Guide Chapter 7 Creating and Applying User-Defined Formats.
Computer Fundamentals Muhammadamin Daneshwar And Masoud Aras Computer Engineering Department Soran University Lecture 6.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
Chapter 10: Accessing Relational Databases (Self-Study)
Introduction to the C Language
Instructor: Raul Cruz-Cano 7/9/2012
Chapter 2: Getting Data into SAS
ORACLE SQL Developer & SQLPLUS Statements
Chapter 1: Introduction to SAS
Instructor: Raul Cruz-Cano
Introduction to the C Language
Topics Introduction to File Input and Output
Data Manipulation (with SQL)
Instructor: Raul Cruz 9/4/13
Objectives In this lesson, you will learn to:
Topics Introduction to File Input and Output
Presentation transcript:

Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William E Benjamin Jr Owl Computer Consultancy, LLC

Copyright 2009 Topic Groups LIBNAME – SYNTAX and DEFAULTS ENGINE-CONNECTION-OPTIONS LIBNAME-OPTIONS DATASET-OPTIONS EXAMPLES QUESTIONS Copyright 2008

Copyright 2009 LIBNAME – SYNTAX and DEFAULTS Simple Syntax Example Part of the syntax (SAS Version 9.2) for accessing Excel files is as follows: LIBNAME libref ; That looks pretty much like every other LIBNAME definition. So let’s make it a little more Excel friendly. LIBNAME xls_data EXCEL ‘C:\WUSS_2009\My_Excel_File.xls’; Default Syntax

Copyright 2009 LIBNAME – SYNTAX and DEFAULTS Simple Syntax Example LIBNAME xls_data EXCEL ‘ C:\WUSS_2009\My_Excel_File.xls ’; This LIBNAME reaches to a FILE not a DIRECTORY Because the file contains other objects Default Syntax

Copyright 2009 LIBNAME – SYNTAX and DEFAULTS Simple Syntax Example Create a Simple Excel File from a SAS File: Data xls_data.’sheet1’n; Set sashelp.shoes; Run; Create an EXCEL file from a SAS File

Copyright 2009 LIBNAME – SYNTAX and DEFAULTS Simple Syntax Example ‘sheet1’n is a “named constant” used to identify the Excel Sheet name. Data xls_data. ’sheet1’n ; Set sashelp.shoes; Run; Default Syntax

Copyright 2009 LIBNAME – SYNTAX and DEFAULTS Simple Syntax Example – After Execution

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax LIBNAME libref ; Now we see ”engine-connection-options” and “libname-options”, these are both little used features of the SAS LIBNAME statements. We will examine these in order and list some examples and outputs from applying these options. Excel Related Syntax

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax HEADER OPTION – HEADER=YES|NO LIBNAME xls_data EXCEL ‘C:\WUSS_2009\My_Excel_File.xls’ HEADER=NO; HEADER=YES is the Default and is implied when not used on LIBNAME statement. ENGINE-CONNECTION-OPTIONS - Example

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax HEADER OPTION – HEADER=YES|NO Changes how the first line of the Excel file is Read  YES (Default) – Convert Line 1 of Excel sheet to SAS Variable names  NO – Line 1 of Excel Sheet is Data  Generate Variable names (F1,F2)  Data in row 1 is subject to “Best-Guess” rules of data conversion  Invalid SAS Variable name characters are converted to “_”  Duplicate names are avoided by adding a number to end of SAS Name ENGINE-CONNECTION-OPTIONS

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax MIXED OPTION – MIXED=YES|NO LIBNAME xls_data EXCEL ‘C:\WUSS_2009\My_Excel_File.xls’ MIXED=YES; MIXED=NO is the Default and is implied when not used on LIBNAME statement. ENGINE-CONNECTION-OPTIONS - Example

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax MIXED OPTION – MIXED=YES|NO Changes how All of the Excel data is Read into SAS for this file  NO (Default) – a specified number of rows of the Excel column are searched and a guess is returned about the data type of the input Excel data field.  YES–  ALL SAS variables are crated as character variables  Excel file is read in import mode  No updates are allowed to the file  The Windows Registry can be changed to modify this behavior, but it will change the behavior for all programs that use the Microsoft Jet/Excel engine. ENGINE-CONNECTION-OPTIONS

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax VERSION OPTION – VERSION= '2003', '2002', '2000', '97', '95', or '5' LIBNAME xls_data EXCEL ‘C:\WUSS_2009\My_Excel_File.xls’ VERSION=97; This option is only valid for Excel Output  VERSION=97 is the Default and is implied when not used on LIBNAME statement.  Only two file formats are available (EXCEL5, and EXCEL )  Quotes are optional ENGINE-CONNECTION-OPTIONS - Example

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax VERSION OPTION – VERSION= '2003', '2002', '2000', '97', '95', or '5' ** NOTE ** Microsoft Excel 2007 is not Supported by SAS/ACCESS for PC files, but Excel 2007 can read all other formats. Data stored in Microsoft Excel 2007 file format (*.xlsx) is stored as components of a “ZIP” file and not supported by SAS/ACCESS for PC files. ENGINE-CONNECTION-OPTIONS

Copyright 2009 ENGINE-CONNECTION-OPTIONS Expanded Syntax

Copyright 2009 LIBNAME-OPTIONS LIBNAME Option General Syntax ACCESS=- Sets READ ONLY mode DBGEN_NAME=- Specifies how data source column names are created DBMAX_TEXT=- Specifies maximum character string size DBSASLABEL=- Select if Excel Column names are uses as SAS labels DEFER=- Define if the Excel file is opened upon Definition or use DIRECT_SQL=- Define what SQL SAS will send Microsoft Jet/Engine SCAN_TEXTSIZE=- Scan Excel Text columns for the longest variable size SCAN_TIMETYPE=- Determine the type of date/time formats to use STRINGDATES=- Define if date and time values are strings or numeric USE_DATETYPE= - Determine if DATE or DATETIME informats are used LIBNAME xls_data EXCEL ‘C:\WUSS_2009\My_Excel_File.xls’ OPTION=Value;

Copyright 2009 DATASET-OPTIONS DATASET Option General Syntax PROC PRINT DATA=libref.SAS-data-set-name (OPTION-NAME=option-value); Run; Or DATA libref.SAS-data-set-name (OPTION-NAME=option-value); Set libref.SAS-data-set-name (OPTION-NAME=option-value); Run; Dataset Options can be used Wherever and With standard Dataset Options

Copyright 2009 DATASET-OPTIONS DATASET Option General Syntax AUTOCOMMIT=DBCOMMIT= DBCONDITION=DBCREATE_TABLE_OPTS= DBENCODING=DBFORCE= DBGEN_NAME=DBKEY= DBLABEL=DBMAX_TEXT= DBSASLABEL=DBSASTYPE= DBTYPE=INSERT_SQL= READBUFF=SASDATEFMT= Also the Standard DATASET options: DROP=, CNTLLEV=, FIRSTOBS=, IN=, KEEP=, RENAME=, and WHERE= Dataset Options can be used Wherever and With standard Dataset Options

Copyright 2009 EXAMPLES Example 1 – Date Processing SAS Default date, SAS Datetime21.2, and SAS Time8. Formats

Copyright 2009 EXAMPLES Example 2 – Date Processing SAS Default date, SAS numeric field, and SAS character field

Copyright 2009 EXAMPLES Example 3 – Using Standard and Excel Options Complex WHERE= clause, DROP= clause, and Excel options too

Copyright 2009 EXAMPLES EXAMPLE 4 – Reading BOTH Character & numeric data Two SAS programs reading the same file and getting different results v

Copyright 2009 Leave Your Bad Code Behind: 50 Ways to Make Your SAS® Code Execute More Efficiently. QUESTIONS???? William E Benjamin Jr Owl Computer Consultancy, LLC