SAS/ACCESS 9.3 for Relational Databases · The correct bibliographic citation for this manual is as...

978
SAS/ACCESS ® 9.3 for Relational Databases Reference, Second Edition SAS ® Documentation

Transcript of SAS/ACCESS 9.3 for Relational Databases · The correct bibliographic citation for this manual is as...

SAS/ACCESS 9.3 forRelational DatabasesReference, Second Edition

SAS Documentation

The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2012. SAS/ACCESS 9.3 for Relational Databases: Reference,Second Edition. Cary, NC: SAS Institute Inc.

SAS/ACCESS 9.3 for Relational Databases: Reference, Second Edition

Copyright 2012, SAS Institute Inc., Cary, NC, USA

ISBN 978-1-60764-890-1

All rights reserved. Produced in the United States of America.

For a hardcopy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means,electronic, mechanical, photocopying, or otherwise, without the prior written permission of the publisher, SAS Institute Inc.

For a Web download or e-book:Your use of this publication shall be governed by the terms established by the vendor at the time you acquire thispublication.

The scanning, uploading, and distribution of this book via the Internet or any other means without the permission of the publisher is illegal andpunishable by law. Please purchase only authorized electronic editions and do not participate in or encourage electronic piracy of copyrightedmaterials. Your support of others' rights is appreciated.

U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related documentation by the U.S. government issubject to the Agreement with SAS Institute and the restrictions set forth in FAR 52.22719 Commercial Computer Software-Restricted Rights(June 1987).

SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.

1st printing, August 20121st electronic book, August 20122nd electronic book, September 2014

SAS Publishing provides a complete selection of books and electronic products to help customers use SAS software to its fullest potential. Formore information about our e-books, e-learning products, CDs, and hard-copy books, visit the SAS Publishing Web site atsupport.sas.com/publishing or call 1-800-727-3228.

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and othercountries. indicates USA registration.

Other brand and product names are registered trademarks or trademarks of their respective companies.

http://support.sas.com/publishing

Contents

What's New in SAS/ACCESS 9.3 for Relational Databases . . . . . . . . . . . . . . . . . . . . . . xiAccessibility Features of SAS/ACCESS Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvRecommended Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

PART 1 Concepts 1

Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases . . . . . . . . . . . . . . . . . . 3About This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Methods for Accessing Relational Database Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Selecting a SAS/ACCESS Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4SAS Views of DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Choosing Your Degree of Numeric Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Chapter 2 SAS Names and Support for DBMS Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Introduction to SAS/ACCESS Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13SAS Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14SAS/ACCESS Default Naming Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Renaming DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Options That Affect SAS/ACCESS Naming Behavior . . . . . . . . . . . . . . . . . . . . . . . . . 17Naming Behavior When Retrieving DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Naming Behavior When Creating DBMS Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18SAS/ACCESS Naming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19DBMS-Specific Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Chapter 3 Data Integrity and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Introduction to Data Integrity and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29DBMS Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29SAS Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Potential Result Set Differences When Processing Null Data . . . . . . . . . . . . . . . . . . . . 35

Chapter 4 Performance Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Increasing Throughput of the SAS Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Limiting Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Repeatedly Accessing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Sorting DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Temporary Table Support for SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Chapter 5 Optimizing Your SQL Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Overview: Optimizing Your SQL Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Passing Functions to the DBMS Using PROC SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Passing Joins to the DBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Passing the DELETE Statement to Empty a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49When Passing Joins to the DBMS Will Fail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Passing DISTINCT and UNION Processing to the DBMS . . . . . . . . . . . . . . . . . . . . . . 51Optimizing the Passing of WHERE Clauses to the DBMS . . . . . . . . . . . . . . . . . . . . . . 51Using the DBINDEX=, DBKEY=, and MULTI_DATASRC_OPT= Options . . . . . . . 53

Chapter 6 Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Overview: Threaded Reads in SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Underlying Technology of Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57SAS/ACCESS Interfaces and Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Scope of Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Options That Affect Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Generating Trace Information for Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Performance Impact of Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Autopartitioning Techniques in SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Data Ordering in SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Two-Pass Processing for SAS Threaded Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 65When Threaded Reads Do Not Occur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Summary of Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Chapter 7 How SAS/ACCESS Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Introduction to How SAS/ACCESS Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67How the SAS/ACCESS LIBNAME Statement Works . . . . . . . . . . . . . . . . . . . . . . . . . 68How the SQL Pass-Through Facility Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69How the ACCESS Procedure Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70How the DBLOAD Procedure Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Chapter 8 In-Database Processing with SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

PART 2 General Reference 75

Chapter 9 SAS/ACCESS Features by Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77SAS/ACCESS Interface to Aster nCluster: Supported Features . . . . . . . . . . . . . . . . . . 78SAS/ACCESS Interface to DB2 under UNIX and PC Hosts: Supported Features . . . . 78SAS/ACCESS Interface to DB2 under z/OS: Supported Features . . . . . . . . . . . . . . . . . 79SAS/ACCESS Interface to Greenplum: Supported Features . . . . . . . . . . . . . . . . . . . . . 80SAS/ACCESS Interface to Hadoop: Supported Features . . . . . . . . . . . . . . . . . . . . . . . . 80SAS/ACCESS Interface to HP Neoview: Supported Features . . . . . . . . . . . . . . . . . . . . 81SAS/ACCESS Interface to Informix: Supported Features . . . . . . . . . . . . . . . . . . . . . . . 82SAS/ACCESS Interface to Microsoft SQL Server: Supported Features . . . . . . . . . . . . 83SAS/ACCESS Interface to MySQL: Supported Features . . . . . . . . . . . . . . . . . . . . . . . 83SAS/ACCESS Interface to Netezza: Supported Features . . . . . . . . . . . . . . . . . . . . . . . 84SAS/ACCESS Interface to ODBC: Supported Features . . . . . . . . . . . . . . . . . . . . . . . . 85SAS/ACCESS Interface to OLE DB: Supported Features . . . . . . . . . . . . . . . . . . . . . . . 86SAS/ACCESS Interface to Oracle: Supported Features . . . . . . . . . . . . . . . . . . . . . . . . . 87SAS/ACCESS Interface to Sybase: Supported Features . . . . . . . . . . . . . . . . . . . . . . . . 88SAS/ACCESS Interface to Sybase IQ: Supported Features . . . . . . . . . . . . . . . . . . . . . . 89SAS/ACCESS Interface to Teradata: Supported Features . . . . . . . . . . . . . . . . . . . . . . . 90

Chapter 10 The LIBNAME Statement for Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . 91Overview: LIBNAME Statement for Relational Databases . . . . . . . . . . . . . . . . . . . . . . 93Assigning a Libref Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Chapter 11 Data Set Options for Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203About the Data Set Options for Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . 207Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

iv Contents

Chapter 12 Macro Variables and System Options for Relational Databases . . . . . . . . . . . . . 375Introduction to Macro Variables and System Options . . . . . . . . . . . . . . . . . . . . . . . . . 375Macro Variables for Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375System Options for Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

Chapter 13 The SQL Pass-Through Facility for Relational Databases . . . . . . . . . . . . . . . . . . 401About SQL Procedure Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401Syntax: SQL Pass-Through Facility for Relational Databases . . . . . . . . . . . . . . . . . . . 403Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

PART 3 DBMS-Specific Reference 413

Chapter 14 SAS/ACCESS Interface to Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415Introduction to SAS/ACCESS Interface to Aster nCluster . . . . . . . . . . . . . . . . . . . . . 416LIBNAME Statement Specifics for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . 416Data Set Options for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420SQL Pass-Through Facility Specifics for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . 422Autopartitioning Scheme for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424Passing SAS Functions to Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425Passing Joins to Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426Bulk Loading for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427Naming Conventions for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428Data Types for Aster nCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

Chapter 15 SAS/ACCESS Interface to DB2 for UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . 433Introduction to SAS/ACCESS Interface to DB2 under UNIX and PC Hosts . . . . . . . 434LIBNAME Statement Specifics for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . 434Data Set Options for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . . . . . . 438SQL Pass-Through Facility Specifics for DB2 under UNIX and PC Hosts . . . . . . . . . 441Autopartitioning Scheme for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . 443Temporary Table Support for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . 446Calling Stored Procedures in DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . 447DBLOAD Procedure Specifics for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . 450Passing SAS Functions to DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . 452Passing Joins to DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453Bulk Loading for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . 453Locking in the DB2 under UNIX and PC Hosts Interface . . . . . . . . . . . . . . . . . . . . . . 456Naming Conventions for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . . 458Data Types for DB2 under UNIX and PC Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

Chapter 16 SAS/ACCESS Interface to DB2 for z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465Introduction to SAS/ACCESS Interface to DB2 under z/OS . . . . . . . . . . . . . . . . . . . . 467LIBNAME Statement Specifics for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . 467Data Set Options for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470SQL Pass-Through Facility Specifics for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . 473Autopartitioning Scheme for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Temporary Table Support for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Calling Stored Procedures in DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477ACCESS Procedure Specifics for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . 479DBLOAD Procedure Specifics for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . 481The DB2EXT Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482The DB2UTIL Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484Maximizing DB2 under z/OS Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489

Contents v

Passing SAS Functions to DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492Passing Joins to DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493SAS System Options, Settings, and Macros for DB2 under z/OS . . . . . . . . . . . . . . . . 493Bulk Loading for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496Locking in the DB2 under z/OS Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502Naming Conventions for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502Data Types for DB2 under z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503Understanding DB2 under z/OS Client/Server Authorization . . . . . . . . . . . . . . . . . . . 508DB2 under z/OS Information for the Database Administrator . . . . . . . . . . . . . . . . . . . 511

Chapter 17 SAS/ACCESS Interface to Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Introduction to SAS/ACCESS Interface to Greenplum . . . . . . . . . . . . . . . . . . . . . . . . 516LIBNAME Statement Specifics for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516Data Set Options for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519SQL Pass-Through Facility Specifics for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . 521Autopartitioning Scheme for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523Passing SAS Functions to Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525Passing Joins to Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526Bulk Loading for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526Naming Conventions for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530Data Types for Greenplum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

Chapter 18 SAS/ACCESS Interface to Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535Introduction to SAS/ACCESS Interface to Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . 536LIBNAME Statement Specifics for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536Data Set Options for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538SQL Pass-Through Facility Specifics for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539Passing SAS Functions to Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540Passing Joins to Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541Bulk Loading for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541Naming Conventions for Hive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Data Types for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544Sample Code for Hadoop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553

Chapter 19 SAS/ACCESS Interface to HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Introduction to SAS/ACCESS Interface to HP Neoview . . . . . . . . . . . . . . . . . . . . . . . 556LIBNAME Statement Specifics for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Data Set Options for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559SQL Pass-Through Facility Specifics for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . 562Autopartitioning Scheme for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563Temporary Table Support for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Passing SAS Functions to HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566Passing Joins to HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567Bulk Loading and Extracting for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568Naming Conventions for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Data Types for HP Neoview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571

Chapter 20 SAS/ACCESS Interface to Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575Introduction to SAS/ACCESS Interface to Informix . . . . . . . . . . . . . . . . . . . . . . . . . . 576LIBNAME Statement Specifics for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576Data Set Options for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579SQL Pass-Through Facility Specifics for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . 580Autopartitioning Scheme for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583Temporary Table Support for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584Passing SAS Functions to Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585Passing Joins to Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586

vi Contents

Locking in the Informix Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586Naming Conventions for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587Data Types for Informix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588Overview: Informix Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591

Chapter 21 SAS/ACCESS Interface to Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . 593Introduction to SAS/ACCESS Interface to Microsoft SQL Server . . . . . . . . . . . . . . . 593LIBNAME Statement Specifics for Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . 594Data Set Options for Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598SQL Pass-Through Facility Specifics for Microsoft SQL Server . . . . . . . . . . . . . . . . 600DBLOAD Procedure Specifics for Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . 602Passing SAS Functions to Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Locking in the Microsoft SQL Server Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Naming Conventions for Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605Data Types for Microsoft SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605

Chapter 22 SAS/ACCESS Interface to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609Introduction to SAS/ACCESS Interface to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . 609LIBNAME Statement Specifics for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610Data Set Options for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612SQL Pass-Through Facility Specifics for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613Autocommit and Table Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615Understanding MySQL Update and Delete Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615Passing SAS Functions to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616Passing Joins to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617Naming Conventions for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617Data Types for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618Case Sensitivity for MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622

Chapter 23 SAS/ACCESS Interface to Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623Introduction to SAS/ACCESS Interface to Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . 623LIBNAME Statement Specifics for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624Data Set Options for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627SQL Pass-Through Facility Specifics for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629Temporary Table Support for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631Passing SAS Functions to Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632Passing Joins to Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633Bulk Loading and Unloading for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634Naming Conventions for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636Data Types for Netezza . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636

Chapter 24 SAS/ACCESS Interface to ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641Introduction to SAS/ACCESS Interface to ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . 642LIBNAME Statement Specifics for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646Data Set Options for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651SQL Pass-Through Facility Specifics for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652Autopartitioning Scheme for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657DBLOAD Procedure Specifics for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661Temporary Table Support for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663Passing SAS Functions to ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665Passing Joins to ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665Bulk Loading for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666Locking in the ODBC Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666Naming Conventions for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668Data Types for ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668

Contents vii

Chapter 25 SAS/ACCESS Interface to OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671Introduction to SAS/ACCESS Interface to OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . 672LIBNAME Statement Specifics for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672Data Set Options for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679SQL Pass-Through Facility Specifics for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . 680Temporary Table Support for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685Passing SAS Functions to OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687Passing Joins to OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688Bulk Loading for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688Locking in the OLE DB Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689Accessing OLE DB for OLAP Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690Naming Conventions for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692Data Types for OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693

Chapter 26 SAS/ACCESS Interface to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697Introduction to SAS/ACCESS Interface to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698LIBNAME Statement Specifics for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698Data Set Options for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702SQL Pass-Through Facility Specifics for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704Autopartitioning Scheme for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707Temporary Table Support for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709ACCESS Procedure Specifics for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711DBLOAD Procedure Specifics for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712Maximizing Oracle Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714Passing SAS Functions to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715Passing Joins to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716Bulk Loading for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716Locking in the Oracle Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718Naming Conventions for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719Data Types for Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720

Chapter 27 SAS/ACCESS Interface to Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731Introduction to SAS/ACCESS Interface to Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . 732LIBNAME Statement Specifics for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732Data Set Options for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735SQL Pass-Through Facility Specifics for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737Autopartitioning Scheme for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739Temporary Table Support for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740ACCESS Procedure Specifics for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742DBLOAD Procedure Specifics for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743Passing SAS Functions to Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745Passing Joins to Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746Bulk Loading for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746Reading Multiple Sybase Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746Locking in the Sybase Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747Naming Conventions for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748Data Types for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749Case Sensitivity in Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756National Language Support for Sybase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756

Chapter 28 SAS/ACCESS Interface to Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757Introduction to SAS/ACCESS Interface to Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . 758LIBNAME Statement Specifics for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758Data Set Options for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 762SQL Pass-Through Facility Specifics for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . 764Autopartitioning Scheme for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765

viii Contents

Passing SAS Functions to Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767Passing Joins to Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767Bulk Loading for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768Locking in the Sybase IQ Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 769Naming Conventions for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770Data Types for Sybase IQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 771

Chapter 29 SAS/ACCESS Interface to Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777Introduction to SAS/ACCESS Interface to Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . 778LIBNAME Statement Specifics for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779Data Set Options for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784SQL Pass-Through Facility Specifics for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . 787Autopartitioning Scheme for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789Temporary Table Support for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793Passing SAS Functions to Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796Passing Joins to Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Maximizing Teradata Read Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797Maximizing Teradata Load Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801Teradata Processing Tips for SAS Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810Locking in the Teradata Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814Naming Conventions for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818Data Types for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820Temporal Data Types for Teradata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825

PART 4 Sample Code 829

Chapter 30 Accessing DBMS Data with the LIBNAME Statement . . . . . . . . . . . . . . . . . . . . . . 831Overview: LIBNAME Statement Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831Examples: Create SAS Data Sets from DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . 832Examples: Use the SQL Procedure with DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . 836Examples: Use Other SAS Procedures with DBMS Data . . . . . . . . . . . . . . . . . . . . . . 844Example: Calculate Statistics from DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849Example: Select and Combine DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850Example: Join DBMS and SAS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 851

Chapter 31 Accessing DBMS Data with the SQL Pass-Through Facility . . . . . . . . . . . . . . . . 853Overview: SQL Pass-Through Facility Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . 853Example: Retrieve DBMS Data with a Pass-Through Query . . . . . . . . . . . . . . . . . . . 854Example: Combine an SQL View with a SAS Data Set . . . . . . . . . . . . . . . . . . . . . . . 856Example: Use a Pass-Through Query in a Subquery . . . . . . . . . . . . . . . . . . . . . . . . . . 857

Chapter 32 Sample Data for SAS/ACCESS for Relational Databases . . . . . . . . . . . . . . . . . . . 861Introduction to the Sample Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861Descriptions of the Sample Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861

PART 5 Converting SAS/ACCESS Descriptors to PROCSQL Views 867

Chapter 33 CV2VIEW Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869Overview: CV2VIEW Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869Syntax: CV2VIEW Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870

Contents ix

Examples: CV2VIEW Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875

PART 6 Appendixes 879

Appendix 1 ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881Overview: ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881DBMS Specifics: ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883Syntax: ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884Using Descriptors with the ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896Examples: ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 898

Appendix 2 DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901Overview: DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901DBMS Specifics: DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903Syntax: DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903Examples: DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925

x Contents

What's New in SAS/ACCESS 9.3for Relational Databases

Overview

SAS/ACCESS 9.3 for Relational Databases has these new features and enhancements.

new SAS/ACCESS Interface to Hadoop in March 2012

updated operating environments for various SAS/ACCESS interfaces

new nicknames

new function and options for the Teradata interface

documentation enhancements

Operating Environments Updates

Operating environments for specific SAS/ACCESS interfaces have changed. SeeSAS/ACCESS Features by Host for the operating environments that your interfacesupports.

New Nicknames

These interfaces have new nicknames.

SAS/ACCESS Interface to Aster nCluster: aster

SAS/ACCESS Interface to Greenplum: greenplm

SAS/ACCESS Interface to Sybase IQ: sybaseiq

xi

Second Maintenance Release for SAS 9.3:General Changes

In the second maintenance release for SAS 9.3, the default value for theSQLGENERATION= LIBNAME and system options includes Aster nCluster andGreenplum.

SAS/ACCESS Interface to Aster nCluster

In the second maintenance release for SAS 9.3, the default PORT= number for theLIBNAME statement has changed.

SAS/ACCESS Interface to Hadoop

In the March 2012 release for SAS 9.3, SAS/ACCESS Interface to Hadoop is a newdatabase engine. It provides direct, transparent access to Apache Hadoop throughLIBNAME statements and the SQL pass-through facility. You can use variousLIBNAME statement options and data set options that the LIBNAME engine supports tocontrol the data that is returned to SAS.

For details about SAS interfaces to Hadoop, see these topics or documents.

SAS/ACCESS Interface to Hadoop

SAS/ACCESS Interface to Hadoop: Supported Features

PROC HADOOP in Base SAS Procedures Guide

FILENAME statement (file access method) in SAS Statements: Reference

In the second maintenance release for SAS 9.3, these items are new or enhanced.

You can specify a Hadoop configuration file in a CONNECTION statement or as aconnection option in the LIBNAME statement.

DBCREATE_TABLE_EXTERNAL= LIBNAME and data set options are new.

The DBCREATE_TABLE_LOCATION= data set option is new.

DBCREATE_TABLE_OPTS= LIBNAME and data set options are new.

The LENGTH and TRIMN functions are now automatically passed down by default.

SAS/ACCESS Interface to Oracle

In the second maintenance release for SAS 9.3, these items are new.

xii SAS/ACCESS for Relational Databases

DB_OBJECTS= LIBNAME option

OR_BINARY_DOUBLE= LIBNAME option

SAS/ACCESS Interface to Teradata

These items are new.

Temporal qualifiers let you specify time-dimension criteria for retrieving data fromTeradata. For details, see the section about temporal data types, including how to usethem in a LIBNAME statement or a DATA step.

Using the DBCONSTRAINT= data set option, you can specify with table-leveldefinitions where to create a table.

In the second maintenance release for SAS 9.3, these items are new or enhanced.

The enhanced LOGDB= LIBNAME option now also works with the TPT API.

The SLEEP= and TENACITY= data set options are enhanced, and correspondingSLEEP= and TENACITY= LIBNAME options are new.

The new TR_ENABLE_INTERRUPT= LIBNAME option lets you cancel anexecuting Teradata query.

Documentation Enhancements

This document includes these changes.

SAS In-Database information is now in the SAS In-Database Products:Administrators Guide and the SAS In-Database Products: User's Guide. See alsothe In-Database Processing with SAS/ACCESS topic.

For the MySQL interface, you can use the RESULTS= LIBNAME option to specifywhere you want to store query results.

Documentation Enhancements xiii

xiv SAS/ACCESS for Relational Databases

Accessibility Features ofSAS/ACCESS Interfaces

SAS/ACCESS relational database interfaces include accessibility and compatibilityfeatures that improve usability of the product for users with disabilities. These featuresare related to accessibility standards for electronic information technology adopted bythe U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, asamended.

xv

xvi Accessibility Features of SAS/ACCESS Interfaces

Recommended Reading

Here is the recommended reading list for this title.

Base SAS Procedures Guide

Base SAS Utilities: Reference

SAS/ACCESS Interface to PC Files: Reference

SAS Companion for your operating environment

SAS Component Objects: Reference

SAS Data Set Options: Reference

SAS Formats and Informats: Reference

SAS Functions and CALL Routines: Reference

SAS In-Database Products: Administrator's Guide

SAS In-Database Products: User's Guide

SAS Intelligence Platform: Security Administration Guide

SAS Language Reference: Concepts

SAS Macro Language: Reference

SAS/SHARE User's Guide

SAS System Options: Reference

SAS Statements: Reference

For a complete list of SAS publications, go to support.sas.com/bookstore. If you havequestions about which titles you need, please contact a SAS Publishing SalesRepresentative:

SAS Publishing SalesSAS Campus DriveCary, NC 27513-2414Phone: 1-800-727-3228Fax: 1-919-677-8166E-mail: [email protected] address: support.sas.com/bookstore

xvii

mailto:[email protected]://support.sas.com/bookstore

xviii Recommended Reading

Part 1

Concepts

Chapter 1Overview of SAS/ACCESS Interface to Relational Databases . . . . . . . 3

Chapter 2SAS Names and Support for DBMS Names . . . . . . . . . . . . . . . . . . . . . . . 13

Chapter 3Data Integrity and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Chapter 4Performance Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Chapter 5Optimizing Your SQL Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Chapter 6Threaded Reads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Chapter 7How SAS/ACCESS Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Chapter 8In-Database Processing with SAS/ACCESS . . . . . . . . . . . . . . . . . . . . . . 73

1

2

Chapter 1

Overview of SAS/ACCESSInterface to Relational Databases

About This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Methods for Accessing Relational Database Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Selecting a SAS/ACCESS Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Methods for Accessing DBMS Tables and Views . . . . . . . . . . . . . . . . . . . . . . . . . . . 4SAS/ACCESS LIBNAME Statement Advantages . . . . . . . . . . . . . . . . . . . . . . . . . . . 4SQL Pass-Through Facility Advantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5SAS/ACCESS Features for Common Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

SAS Views of DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Choosing Your Degree of Numeric Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Factors That Can Cause Calculation Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Examples of Problems That Result in Numeric Imprecision . . . . . . . . . . . . . . . . . . . 8Your Options When Choosing the Degree of Precision That You Need . . . . . . . . . 10References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

About This DocumentThis document provides conceptual, reference, and usage information for SAS/ACCESSsoftware for data sources for relational database management systems (DBMSs), datawarehouse appliances, and Hadoop Distributed File System (HDFS). The information inthis document applies to all data sources that SAS/ACCESS software supports.

The availability and behavior of SAS/ACCESS features vary from one interface toanother. You should therefore consult the information in both the general and DBMS-specific sections of this document when working with your particular SAS/ACCESSinterface. You should also refer to the SAS system requirements and configuration guidedocuments that are available at http://support.sas.com.

This document is intended for applications programmers and end users with these skills.

They are familiar with the basics of their DBMS or data warehouse appliance and itsStructured Query Language (SQL).

If they are using Hadoop, they are familiar with Hadoop and the Hadoop DistributedFile System (HDFS). They have knowledge of fundamental Hadoop library andprocessing using HDFS. They are also familiar with the basics of Hadoop, Hive, andHiveQL. For details, see the Apache Hadoop and Hive Web sites at http://hadoop.apache.org and https://cwiki.apache.org/confluence/display/Hive.

3

They know how to use their operating environment.

They can use basic SAS commands and statements.

Database administrators might also want to read this document to understand how toimplement and administer specific interfaces.

Methods for Accessing Relational Database DataSAS/ACCESS Interface to Relational Databases is a family of interfaceseach licensedseparatelywith which you can interact with data in other vendor databases from withinSAS. SAS/ACCESS provides these methods for accessing relational DBMS data.

To assign SAS librefs to DBMS objects such as schemas and databases, you can usethe LIBNAME statement on page 93 . After you associate a database with a libref,you can use a SAS two-level name to specify any table or view in the database. Youcan then work with the table or view as you would with a SAS data set.

To interact with a data source using its native SQL syntax without leaving your SASsession, you can use the SQL pass-through facility on page 403. SQL statements arepassed directly to the data source for processing.

For indirect access to DBMS data, you can use the ACCESS on page 881 andDBLOAD on page 901 procedures. Although SAS still supports these proceduresfor database systems and environments on which they were available for SAS 6, theyare no longer the recommended method for accessing DBMS data.

For information about when to use each method, see Selecting a SAS/ACCESSMethod on page 4.

Not all SAS/ACCESS interfaces support all of these features. To determine whichfeatures are available in your environment, see Introduction on page 77.

Selecting a SAS/ACCESS Method

Methods for Accessing DBMS Tables and ViewsYou can often complete a task in SAS/ACCESS in several ways. For example, you canaccess DBMS tables and views by using the LIBNAME statement on page 93 or theSQL pass-through facility on page 403. Before processing complex or data-intensiveoperations, you might want to test several methods first to determine the most efficientone for your particular task.

SAS/ACCESS LIBNAME Statement AdvantagesYou should use the SAS/ACCESS LIBNAME statement for the fastest and most directmethod of accessing your DBMS data except when you need to use SQL that is notANSI-standard. ANSI-standard SQL is required when you use the SAS/ACCESS libraryengine in the SQL procedure. However, the SQL pass-through facility accepts all SQLextensions that your DBMS provides.

Here are the advantages of using the SAS/ACCESS LIBNAME statement.

4 Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases

Significantly fewer lines of SAS code are required to perform operations on yourDBMS. For example, a single LIBNAME statement establishes a connection to yourDBMS, lets you specify how data is processed, and lets you easily view your DBMStables in SAS.

You do not need to know the SQL language of your DBMS to access and manipulatedata on your DBMS. You can use such SAS procedures as PROC SQL or DATAstep programming on any libref that references DBMS data. You can read, insert,update, delete, and append data. You can also create and drop DBMS tables by usingSAS syntax.

The LIBNAME statement gives you more control over DBMS operations such aslocking, spooling, and data type conversion through the use of LIBNAME and dataset options.

The engine can optimize processing of joins and WHERE clauses by passing themdirectly to the DBMS, which takes advantage of the indexing and other processingcapabilities of your DBMS. For more information, see Overview: Optimizing YourSQL Usage on page 45.

The engine can pass some functions directly to the DBMS for processing.

SQL Pass-Through Facility AdvantagesHere are the advantages of using the SQL pass-through facility.

You can use SQL pass-through facility statements so the DBMS can optimizequeries, particularly when you join tables. The DBMS optimizer can take advantageof indexes on DBMS columns to process a query more quickly and efficiently.

SQL pass-through facility statements let the DBMS optimize queries when querieshave summary functions (such as AVG and COUNT), GROUP BY clauses, orcolumns that expressions create (such as the COMPUTED function). The DBMSoptimizer can use indexes on DBMS columns to process queries more rapidly.

On some DBMSs, you can use SQL pass-through facility statements with SAS/AFapplications to handle transaction processing of DBMS data. Using a SAS/AFapplication gives you complete control of COMMIT and ROLLBACK transactions.SQL pass-through facility statements give you better access to DBMS return codes.

The SQL pass-through facility accepts all extensions to ANSI SQL that your DBMSprovides.

SAS/ACCESS Features for Common TasksHere is a list of tasks and the features that you can use to accomplish them.

Table 1.1 SAS/ACCESS Features for Common Tasks

Task SAS/ACCESS Features

Read DBMStables or views

LIBNAME statement*

SQL pass-through facility

View descriptors**

Selecting a SAS/ACCESS Method 5

Task SAS/ACCESS Features

Create DBMSobjects, such astables

LIBNAME statement*

DBLOAD procedure

SQL pass-through facility EXECUTE statement

Update, delete,or insert rowsinto DBMStables

LIBNAME statement*

View descriptors**

SQL pass-through facility EXECUTE statement

Append data toDBMS tables

DBLOAD procedure with APPEND option

LIBNAME statement and APPEND procedure*

SQL pass-through facility EXECUTE statement

SQL pass-through facility INSERT statement

List DBMStables

LIBNAME statement and SAS Explorer window*

LIBNAME statement and DATASETS procedure*

LIBNAME statement and CONTENTS procedure*

LIBNAME statement and SQL procedure dictionary tables*

Delete DBMStables or views

LIBNAME statement and SQL procedure DROP TABLE statement*

LIBNAME statement and DATASETS procedure DELETE statement*

DBLOAD procedure with SQL DROP TABLE statement

SQL pass-through facility EXECUTE statement

* LIBNAME statement refers to the SAS/ACCESS LIBNAME statement.** View descriptors refer to view descriptors that are created in the ACCESS procedure.

SAS Views of DBMS DataSAS/ACCESS lets you create a SAS view of data that exists in a relational databasemanagement system. A SAS data view defines a virtual data set that is named and storedfor later use. A view contains no data, but rather describes data that is stored elsewhere.Here are the types of SAS data views.

DATA step viewsstored, compiled DATA step programs.

6 Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases

SQL viewsare stored query expressions that read data values from their underlying files, whichcan include SAS data files, SAS/ACCESS views, DATA step views, other SQLviews, or relational database data.

SAS/ACCESS views (also called view descriptors)describe data that is stored in DBMS tables. This is no longer a recommendedmethod for accessing relational DBMS data. To convert existing view descriptorsinto SQL views, use the CV2View procedure on page 869.

You can use all types of views as inputs into DATA steps and procedures. You canspecify views in queries as if they were tables. A view derives its data from the tables orviews that are listed in its FROM clause. The data accessed by a view is a subset orsuperset of the data in its underlying table(s) or view(s).

You can use SQL views and SAS/ACCESS views to update their underlying data if theview is based on only one DBMS table or if it is based on a DBMS view that is based ononly one DBMS table and if the view has no calculated fields. You cannot use DATAstep views to update the underlying data; you can use them only to read the data.

Your options for creating a SAS view of DBMS data are determined by theSAS/ACCESS feature that you are using to access the DBMS data. This table lists therecommended methods for creating SAS views.

Table 1.2 Creating SAS Views

Feature for Accessing DBMS Data SAS View Technology to Use

SAS/ACCESS LIBNAME statement SQL view or DATA step view of the DBMS table

SQL pass-through facility SQL view with CONNECTION TO component

Choosing Your Degree of Numeric Precision

Factors That Can Cause Calculation DifferencesDifferent factors affect numeric precision. This issue is common for many people,including SAS users. Though computers and software can help, you are limited in howprecisely you can calculate, compare, and represent data. Therefore, only those peoplewho generate and use data can determine the exact degree of precision that suits theirenterprise needs.

As you decide the degree of precision that you want, you need to consider that thesesystem factors can cause calculation differences:

hardware limitations

differences among operating systems

different software or different versions of the same software

different database management systems (DBMSs)

These factors can also cause differences:

the use of finite number sets to represent infinite real numbers

Choosing Your Degree of Numeric Precision 7

how numbers are stored, because storage sizes can vary

You also need to consider how conversions are performedon, between, or across anyof these system or calculation factors.

Examples of Problems That Result in Numeric Imprecision

OverviewDepending on the degree of precision that you want, calculating the value of r can resultin a tiny residual in a floating-point unit. When you compare the value of r to 0.0, youmight find that r0.0. The numbers are very close but not equal. This type ofdiscrepancy in results can stem from problems in representing, rounding, displaying, andselectively extracting data.

Representing DataSome numbers can be represented exactly, but others cannot. As shown in this example,the number 10.25, which terminates in binary, can be represented exactly.

data x; x=10.25; put x hex16.;run;

The output from this DATA step is an exact number: 4024800000000000. However, thenumber 10.1 cannot be represented exactly, as this example shows.

data x; x=10.1; put x hex16.;run;

The output from this DATA step is an inexact number: 4024333333333333.

Rounding DataAs this example shows, rounding errors can result from platform-specific differences.No solution exists for such situations.

data x; x=10.1; put x hex16.; y=100000; newx=(x+y)-y; put newx hex16.; run;

In Windows and Linux environments, the output from this DATA step is4024333333333333 (8/10-byte hardware double). In the Solaris x64 environment, theoutput is 4024333333334000 (8/8-byte hardware double).

Displaying DataFor certain numbers such as x.5, the precision of displayed data depends on whether youround up or down. Low-precision formatting (rounding down) can produce differentresults on different platforms. In this example, the same high-precision (rounding up)result occurs for X=8.3, X=8.5, or X=hex16. However, a different result occurs forX=8.1 because this number does not yield the same level of precision.

8 Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases

data; x=input('C047DFFFFFFFFFFF', hex16.); put x= 8.1 x= 8.3 x= 8.5 x= hex16.;run;

Here is the output under Windows or Linux (high-precision formatting).

x=-47.8x=-47.750 x=-47.7500x=C047DFFFFFFFFFFF

Here is the output under Solaris x64 (low-precision formatting).

x=-47.7x=-47.750 x=-47.7500x=C047DFFFFFFFFFFF

To fix the problem that this example illustrates, you must select a number that yields thenext precision levelin this case, 8.2.

Selectively Extracting DataResults can also vary when you access data that is stored on one system by using a clienton a different system. This example illustrates running a DATA step from a Windowsclient to access SAS data in the z/OS environment.

data z(keep=x); x=5.2; output; y=1000; x=(x+y)-y; /*almost 5.2 */ output;run;

proc print data=z;run;

Here is the output this DATA step produces.

Obs x1 5.22 5.2

The next example illustrates the output that you receive when you execute the DATAstep interactively under Windows or under z/OS.

data z1; set z(where=(x=5.2));run;

Here is the corresponding z/OS output.

NOTE: There were 1 observations read from the data set WORK.Z.WHERE x=5.2;NOTE: The data set WORK.Z1 has 1 observations and 1 variables.The DATA statement used 0.00 CPU seconds and 14476K.

In the above example, the expected count was not returned correctly under z/OS becausethe imperfection of the data and finite precision are not taken into account. You cannotuse equality to obtain a correct count because it does not include the almost 5.2 casesin that count. To obtain the correct results under z/OS, you must run this DATA step:

Choosing Your Degree of Numeric Precision 9

data z1; set z(where=(compfuzz(x,5.2,1e-10)=0));run;

Here is the z/OS output from this DATA step.

NOTE: There were 2 observations read from the data set WORK.Z.WHERE COMPFUZZ(x, 5.2, 1E-10)=0;NOTE: The data set WORK.Z1 has 2 observations and 1 variables.

Your Options When Choosing the Degree of Precision That YouNeed

After you determine the degree of precision that your enterprise needs, you can refineyour software. You can use macros, sensitivity analyses, or fuzzy comparisons such asextractions or filters to extract data from databases or from different versions of SAS.

If you are running SAS 9.2, use the COMPFUZZ (fuzzy comparison) function.Otherwise, use this macro.

/*****************************************************************************//* This macro defines an EQFUZZ operator. The subsequent DATA step shows *//* how to use this operator to test for equality within a certain tolerance. *//*****************************************************************************/%macro eqfuzz(var1, var2, fuzz=1e-12);abs((&var1 - &var2) / &var1) < &fuzz%mend;

data _null_; x=0; y=1; do i=1 to 10; x+0.1; end; if x=y then put 'x exactly equal to y'; else if %eqfuzz(x,y) then put 'x close to y'; else put 'x nowhere close to y';run;

When you read numbers in from an external DBMS that supports precision beyond 15digits, you can lose that precision. You cannot do anything about this for existingdatabases. However, when you design new databases, you can set constraints to limitprecision to about 15 digits or you can select a numeric DBMS data type to match thenumeric SAS data type. For example, select the BINARY_DOUBLE type in Oracle(precise up to 15 digits) instead of the NUMBER type (precise up to 38 digits).

When you read numbers in from an external DBMS for noncomputational purposes, usethe DBSASTYPE= data set option, as shown in this example.

libname ora oracle user=scott password=tiger path=path;data sasdata; set ora.catalina2( dbsastype= ( c1='char(20)') ) ;run;

This option retrieves numbers as character strings and preserves precision beyond 15digits. For details, see the DBSASTYPE= data set option on page 298 .

10 Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases

ReferencesSee these resources for more detail about numeric precision, including variables that canaffect precision.

The Aggregate. 2008. "Numerical Precision, Accuracy, and Range," Aggregate.org:Unbridled Computing. Lexington, KY: University of Kentucky. Available athttp://aggregate.org/NPAR. Accessed on July 30, 2012.

IEEE. 2008. IEEE 754: Standard for Binary Floating-Point Arithmetic. Availableat http://grouper.ieee.org/groups/754/index.html. This standarddefines 32-bit and 64-bit floating-point representations and computational results.Accessed on July 30, 2012.

SAS Institute Inc. 2007. TS-230. Dealing with Numeric Representation Error in SASApplications. Cary, NC: SAS Institute Inc. Available at http://support.sas.com/techsup/technote/ts230.html. Accessed on July 30,2012.

SAS Institute Inc. 2007. TS-654. Numeric Precision 101. Cary, NC: SAS InstituteInc. Available at http://support.sas.com/techsup/technote/ts654.pdf. This document is an overview of numeric precision and how it isrepresented in SAS applications. Accessed on July 30, 2012.

Choosing Your Degree of Numeric Precision 11

12 Chapter 1 Overview of SAS/ACCESS Interface to Relational Databases

Chapter 2

SAS Names and Support forDBMS Names

Introduction to SAS/ACCESS Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

SAS Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Length of Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Case Sensitivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14SAS Name Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

SAS/ACCESS Default Naming Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Modification and Truncation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15ACCESS Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15DBLOAD Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Renaming DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Renaming SAS/ACCESS Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Renaming SAS/ACCESS Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Renaming SAS/ACCESS Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Options That Affect SAS/ACCESS Naming Behavior . . . . . . . . . . . . . . . . . . . . . . . 17

Naming Behavior When Retrieving DBMS Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Naming Behavior When Creating DBMS Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 18

SAS/ACCESS Naming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Replacing Unsupported Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Preserving Column Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Preserving Table Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Using DQUOTE=ANSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Using Name Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Using DBMS Data to Create a DBMS Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Using a SAS Data Set to Create a DBMS Table . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

DBMS-Specific Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Introduction to SAS/ACCESS NamingBecause some DBMSs allow case-sensitive names and names with special characters,show special consideration when you use names of such DBMS objects as tables andcolumns with SAS/ACCESS features. This section presents SAS/ACCESS namingconventions, default naming behaviors, options that can modify naming behavior, andusage examples. See the documentation for your SAS/ACCESS interface for informationabout how SAS handles your DBMS names.

13

SAS Naming Conventions

Length of NameSAS naming conventions allow long names for SAS data sets and SAS variables. Forexample, MYDB.TEMP_EMPLOYEES_QTR4_2000 is a valid two-level SAS name fora data set.

The names of these SAS language elements can be up to 32 characters in length:

members of SAS libraries, including SAS data sets, data views, catalogs, catalogentries, and indexes

variables in a SAS data set

macros and macro variables

These SAS language elements have a maximum length of eight characters:

librefs and filerefs

SAS engine names

names of SAS/ACCESS access descriptors and view descriptors

variable names in SAS/ACCESS access descriptors and view descriptors

For a complete description of SAS naming conventions, see the SAS LanguageReference: Concepts.

Case SensitivityWhen SAS encounters mixed-case or case-sensitive names in SAS code, SAS stores anddisplays the names as they are specified. If the SAS variables, Flight and dates, aredefined in mixed casefor example:

input Flight $3. +3 dates date9.;

Then SAS displays the variable names as defined. The column headings appear asdefined.

Output 2.1 Mixed-Case Names Displayed in Output

SAS System

Obs Flight dates

1 114 01MAR2000 2 202 01MAR2000 3 204 01MAR2000

Although SAS stores variable names as they are defined, it recognizes variables forprocessing without regard to case. For example, SAS processes these variables asFLIGHT and DATES. Likewise, renaming the Flight variable to "flight" or "FLIGHT"would result in the same processing.

14 Chapter 2 SAS Names and Support for DBMS Names

SAS Name LiteralsA SAS name literal is a name token that is expressed as a quoted string, followed by theletter n. Name literals enable you to use special characters or blanks that are nototherwise allowed in SAS names when you specify a SAS data set or variable. Nameliterals are especially useful for expressing database column and tables names thatcontain special characters.

Here are two examples of name literals.

data mydblib.'My Staff Table'n;

data Budget_for_1999; input '$ Amount Budgeted'n 'Amount Spent'n;

Name literals are subject to certain restrictions.

You can use a name literal only for SAS variable and data set names, statementlabels, and DBMS column and table names.

You can use name literals only in a DATA step or in the SQL procedure.

If a name literal contains any characters that are not allowed whenVALIDVARNAME=V7, you must set the system option toVALIDVARNAME=ANY. For more information, see VALIDVARNAME= onpage 398.

SAS/ACCESS Default Naming Behaviors

Modification and TruncationWhen SAS/ACCESS reads DBMS column names that contain characters that are notstandard in SAS names, the default behavior is to replace an unsupported character withan underscore (_). (Nonstandard names include those with blank spaces or such specialcharacters as @, #, % that are not allowed in SAS names.) For example, the DBMScolumn name Amount Budgeted$ becomes the SAS variable name Amount_Budgeted_.

When SAS/ACCESS encounters a DBMS name that exceeds 32 characters, it truncatesthe name.

After it has modified or truncated a DBMS column name, SAS appends a number to thevariable name, if necessary, to preserve uniqueness. For example, DBMS column namesMY$DEPT, My$Dept, and my$dept become SAS variable names MY_DEPT,MY_Dept0, and my_dept1.

ACCESS ProcedureIf you attempt to use long names in the ACCESS procedure, you receive an errormessage advising you that long names are not supported. Long member names, such asaccess descriptor and view descriptor names, are truncated to eight characters. LongDBMS column names are truncated to 8-character SAS variable names within the SASaccess descriptor. You can use the RENAME on page 890 statement to specify 8-character SAS variable names, or you can accept the default truncated SAS variablenames that are assigned by the ACCESS procedure.

SAS/ACCESS Default Naming Behaviors 15

The ACCESS procedure converts DBMS object names to uppercase characters unlessthey are enclosed in quotation marks. Any DBMS objects that are given lowercasenames when they are created, or whose names contain special or national characters,must be enclosed in quotation marks.

DBLOAD ProcedureYou can use long member names, such as the name of a SAS data set that you want toload into a DBMS table, in the DBLOAD procedure DATA= option. However, if youattempt to use long SAS variable names, you receive an error message advising you thatlong variable names are not supported in the DBLOAD procedure. You can use theRENAME on page 911 statement to rename the 8-character SAS variable names to longDBMS column names when you load the data into a DBMS table. You can also use theSAS data set option RENAME to rename the columns after they are loaded into theDBMS.

Most DBLOAD procedure statements convert lowercase characters in user-specifiedvalues and default values to uppercase. If your host or database is case sensitive and youwant to specify a value that includes lowercase alphabetic characters (for example, auser ID or password), enclose the entire value in quotation marks. You must also putquotation marks around any value that contains special characters or national characters.

The only exception is the DBLOAD SQL on page 912 statement. The DBLOAD SQLstatement is passed to the DBMS exactly as you enter it with case preserved.

Renaming DBMS Data

Renaming SAS/ACCESS TablesYou can rename DBMS tables and views using the CHANGE statement, as shown inthis example.

proc datasets lib=x; change oldtable=newtable;quit;

You can rename tables using this method for all SAS/ACCESS engines. However, if youchange a table name, any view that depends on that table no longer works unless theview references the new table name.

Renaming SAS/ACCESS ColumnsYou can use the RENAME on page 911 statement to rename the 8-character defaultSAS variable names to long DBMS column names when you load the data into a DBMStable. You can also use the SAS data set option RENAME= to rename the columns afterthey are loaded into the DBMS.

Renaming SAS/ACCESS VariablesYou can use the RENAME on page 890 statement to specify 8-character SAS variablenames such as access descriptors and view descriptors.

16 Chapter 2 SAS Names and Support for DBMS Names

Options That Affect SAS/ACCESS NamingBehavior

To change how SAS handles case-sensitive or nonstandard DBMS table and columnnames, specify one or more of these options.

PRESERVE_COL_NAMES=YESa SAS/ACCESS LIBNAME and data set option that applies only to creating DBMStables. When set to YES, this option preserves spaces, special characters, and mixedcase in DBMS column names. For more information, see thePRESERVE_COL_NAMES= LIBNAME on page 167 and data set on page336options.

PRESERVE_TAB_NAMES=YESa SAS/ACCESS LIBNAME option. When set to YES, this option preserves blankspaces, special characters, and mixed case in DBMS table names. Specify thePRESERVE_NAMES=YES | NO alias if you plan to specify both thePRESERVE_COL_NAMES= and PRESERVE_TAB_NAMES= options in yourLIBNAME statement. Using this alias saves time when you are coding. For moreinformation, see the PRESERVE_TAB_NAMES= LIBNAME option on page 168.

DQUOTE=ANSIa PROC SQL option. This option specifies whether PROC SQL treats values withindouble quotation marks as a character string or as a column name or table name.When you specify DQUOTE=ANSI, your SAS code can refer to DBMS names thatcontain characters and spaces that are not allowed by SAS naming conventions.Specifying DQUOTE=ANSI enables you to preserve special characters in table andcolumn names in your SQL statements by enclosing the names in double quotationmarks. To preserve table names, you must also specifyPRESERVE_TAB_NAMES=YES. To preserve column names when you create atable, you must also specify PRESERVE_COL_NAMES=YES.

VALIDVARNAME=ANYa global system option that can override the SAS naming conventions. For moreinformation, see the VALIDVARNAME= system option on page 398.

Examples on page 19 that use these options are available. The availability of theseoptions and their default settings are DBMS-specific, so see the SAS/ACCESSdocumentation for your DBMS to learn how the SAS/ACCESS engine for your DBMSprocesses names.

Naming Behavior When Retrieving DBMS DataThe tables in this section illustrate how SAS/ACCESS processes DBMS names when itretrieves data from a DBMS. This information applies generally to all interfaces.However, in some cases you need not specify these options because the option defaultvalues are DBMS-specific. For details, see the DBMS-specific reference section for yourSAS/ACCESS interface. Examples on page 19 are available that illustrate the differenttypes of naming actions and defaults.

Naming Behavior When Retrieving DBMS Data 17

Table 2.1 DBMS Column Names to SAS Variable Names When Reading DBMS Data

DBMS Column Name Desired SAS Variable Name Options

Case-sensitive DBMS column name,such as Flight

Case-sensitive SAS variable name,such as Flight

No options are necessary

DBMS column name with charactersthat are not valid in SAS names, suchas My$Flight

Case-sensitive SAS variable namewhere an underscore replaces theinvalid characters, such as My_Flight

No options are necessary

DBMS column name with charactersthat are not valid in SAS names, suchas My$Flight

Nonstandard, case-sensitive SASvariable name, such as My$Flight

PROC SQL DQUOTE=ANSI or, in aDATA or PROC step, use a SASname literal such as 'My$Flight'n andVALIDVARNAME=ANY

Table 2.2 DBMS Table Names to SAS Data Set Names When Reading DBMS Data

DBMS Table Name Desired SAS Data Set Name Options

Default DBMS table name, such asSTAFF

Default SAS data set or member name(uppercase), such as STAFF

PRESERVE_TAB_NAMES=NO

Case-sensitive DBMS table name, suchas Staff

Case-sensitive SAS data set, such asStaff

PRESERVE_TAB_NAMES=YES

DBMS table name with characters thatare not valid in SAS names, such as All$Staff

Nonstandard, case-sensitive SAS dataset name, such as All$Staff

PROC SQLDQUOTE=ANSI andPRESERVE_TAB_NAMES=YES or,in a DATA step or PROC, use a SASname literal such as 'All$Staff'n andPRESERVE_TAB_NAMES=YES

Naming Behavior When Creating DBMS ObjectsThe tables in this section illustrate how SAS/ACCESS handles variable names when itcreates such DBMS objects as tables and views. This information applies generally to allinterfaces. However, in some cases you need not specify these options because theoption default values are DBMS-specific. For details, see the documentation for yourDBMS. Examples on page 19 are available that illustrate the different types of namingactions and defaults.

Table 2.3 SAS Variable Names to DBMS Column Names When Creating Tables

SAS Variable Name as Input Desired DBMS Column Name Options

Any SAS variable name, such as Miles Default DBMS column name(normalized to follow the DBMS'snaming conventions), such as MILES

PRESERVE_COL_NAMES=NO

18 Chapter 2 SAS Names and Support for DBMS Names

SAS Variable Name as Input Desired DBMS Column Name Options

A case-sensitive SAS variable name,such as Miles

Case-sensitive DBMS column name,such as Miles

PRESERVE_COL_NAMES=YES

A SAS variable name with charactersthat are not valid in a normalized SASname, such as Miles-to-Go

Case-sensitive DBMS column namethat matches the SAS name, such asMiles-to-Go

PROC SQL DQUOTE=ANSI andPRESERVE_COL_NAMES=YESor, in a DATA or PROC step, use aSAS name literal andPRESERVE_COL_NAMES=YESand VALIDVARNAME=ANY

Table 2.4 SAS Data Set Names to DBMS Table Names

SAS Data Set Name as Input Desired DBMS Table Name Options

Any SAS data set name, such asPayroll

Default DBMS table name(normalized to follow the DBMS'snaming conventions), such asPAYROLL

PRESERVE_TAB_NAMES=NO

Case-sensitive SAS data set name, suchas Payroll

Case-sensitive DBMS table name,such as Payroll

PRESERVE_TAB_NAMES=YES

Case-sensitive SAS data set name withcharacters that are not valid in anormalized SAS name, such as Payroll-for-QC

Case-sensitive DBMS table name thatmatches the SAS name, such asPayroll-for-QC

PROC SQL DQUOTE=ANSI andPRESERVE_TAB_NAMES=YES or,in a DATA or PROC step, use a SASname literal andPRESERVE_TAB_NAMES=YES

SAS/ACCESS Naming Examples

Replacing Unsupported CharactersIn the following example, a view, myview, is created from the Oracle table, mytable.

proc sql;connect to oracle (user=testuser password=testpass);create view myview as select * from connection to oracle (select "Amount Budgeted$", "Amount Spent$" from mytable);quit;

proc contents data=myview;run;

In the output produced by PROC CONTENTS, the Oracle column names (that wereprocessed by the SQL view of MYTABLE) are renamed to different SAS variable

SAS/ACCESS Naming Examples 19

names: Amount Budgeted$ becomes Amount_Budgeted_ and Amount Spent$ becomesAmount_Spent_.

Preserving Column NamesThe following example uses the Oracle table, PAYROLL, to create a new Oracle table,PAY1, and then prints the table. You can use both PRESERVE_COL_NAMES=YESand the PROC SQL DQUOTE=ANSI options to preserve the case and nonstandardcharacters in the column names. You need not quote the column aliases to preservemixed case. You need only double quotation marks when the column name hasnonstandard characters or blanks.

By default, most SAS/ACCESS interfaces use DBMS-specific rules to set the case oftable and column names. Therefore, even though the new pay1 Oracle table name in thisexample is created in lowercase, Oracle stores the name in uppercase as PAY1. To storethe table name as "pay1", set PRESERVE_TAB_NAMES=NO.

options linesize=120 pagesize=60 nodate;

libname mydblib oracle user=testuser password=testpass path='ora8_servr' schema=hrdept preserve_col_names=yes;

proc sql dquote=ansi;create table mydblib.pay1 as select idnum as "ID #", sex, jobcode, salary, birth as BirthDate, hired as HiredDate from mydblib.payroll order by birth;

title "Payroll Table with Revised Column Names";select * from mydblib.pay1;quit;

SAS recognizes the JOBCODE, SEX, and SALARY column names, whether youspecify them in your SAS code as lowercase, mixed case, or uppercase. SEX,JOBCODE, and SALARY columns in the PAYROLL Oracle table were created inuppercase. They therefore retain this case in the new table unless you rename them. Hereis partial output from the example.

Output 2.2 DBMS Table Created with Nonstandard and Standard Column Names

Payroll Table with Revised Column Names

ID # SEX JOBCODE SALARY BirthDate HiredDate ------------------------------------------------------------------------ 1118 M PT3 11379 16JAN1944:00:00:00 18DEC1980:00:00:00 1065 M ME2 35090 26JAN1944:00:00:00 07JAN1987:00:00:00 1409 M ME3 41551 19APR1950:00:00:00 22OCT1981:00:00:00 1401 M TA3 38822 13DEC1950:00:00:00 17NOV1985:00:00:00 1890 M PT2 91908 20JUL1951:00:00:00 25NOV1979:00:00:00

20 Chapter 2 SAS Names and Support for DBMS Names

Preserving Table NamesThis example uses PROC PRINT to print the DBMS table PAYROLL. The DBMS tablewas created in uppercase. Because PRESERVE_TAB_NAMES=YES, you must specifythe table name in uppercase. (If you set the PRESERVE_TAB_NAMES=NO, you canspecify the DBMS table name in lowercase.) Partial output follows the example.

options nodate linesize=64;libname mydblib oracle user=testuser password=testpass path='ora8_servr' preserve_tab_names=yes;

proc print data=mydblib.PAYROLL; title 'PAYROLL Table';run;

Output 2.3 DBMS Table with a Case-Sensitive Name

PAYROLL TableObs IDNUM SEX JOBCODE SALARY BIRTH1 1919 M TA2 34376 12SEP1960:00:00:002 1653 F ME2 35108 15OCT1964:00:00:003 1400 M ME1 29769 05NOV1967:00:00:004 1350 F FA3 32886 31AUG1965:00:00:005 1401 M TA3 38822 13DEC1950:00:00:00

This next example submits a SAS/ACCESS LIBNAME statement. It then opens the SASExplorer window, which lists the Oracle tables and views that the MYDBLIB librefreferences. The 16 members are listed and all member names are in the case (initialcapitalization) that the Explorer window sets. Table names are capitalized due to thePRESERVE_TAB_NAMES=NO default.

libname mydblib oracle user=testuser pass=testpass;

Display 2.1 SAS Explorer Window Listing DBMS Objects

SAS/ACCESS Naming Examples 21

If you submit a SAS/ACCESS LIBNAME statement withPRESERVE_TAB_NAMES=YES and then open the SAS Explorer window, you see adifferent listing of the Oracle tables and views that the MYDBLIB libref references.

libname mydblib oracle user=testuser password=testpass preserve_tab_names=yes;

Display 2.2 SAS Explorer Window Listing Case-Sensitive DBMS Objects

The 18 members are listed, including one in lowercase and one with a name separated bya blank space. Because PRESERVE_TAB_NAMES=YES, SAS displays the tablesnames in the exact case in which they were created.

Using DQUOTE=ANSIThis example creates a DBMS table with a blank space in its name. Double quotationmarks are used to specify the table name, International Delays. You can also set both ofthe preserve names LIBNAME options by using the alias PRESERVE_NAMES=.

22 Chapter 2 SAS Names and Support for DBMS Names

Because PRESERVE_NAMES=YES, the schema airport is now case sensitive forOracle.

options linesize=64 nodate;

libname mydblib oracle user=testuser password=testpass path='airdata' schema=airport preserve_names=yes;

proc sql dquote=ansi;create table mydblib."International Delays" as select int.flight as "FLIGHT NUMBER", int.dates, del.orig as ORIGIN, int.dest as DESTINATION, del.delay from mydblib.INTERNAT as int, mydblib.DELAY as del where int.dest=del.dest and int.dest='LON';quit;

proc sql dquote=ansi outobs=10; title "International Delays";select * from mydblib."International Delays";

You can use single quotation marks to specify the data value for London(int.dest='LON') in the WHERE clause. Because of the preserve name LIBNAMEoptions, using double quotation marks would cause SAS to interpret this data value as acolumn name.

Output 2.4 DBMS Table with No