292
SAS/ACCESS ® 9.2 Interface to PC Files Reference

SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

  • Upload
    vothu

  • View
    234

  • Download
    3

Embed Size (px)

Citation preview

Page 1: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

SAS/ACCESS ® 9.2 Interface to PC FilesReference

Page 2: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2009.SAS/ACCESS ® 9.2 Interface to PC Files: Reference. Cary, NC: SAS Institute Inc.

SAS/ACCESS® 9.2 Interface to PC Files: ReferenceCopyright © 2009, SAS Institute Inc., Cary, NC, USAISBN 978-1-59994-710-5All rights reserved. Produced in the United States of America.For a hardcopy book: No part of this publication may be reproduced, stored in aretrieval system, or transmitted, in any form or by any means, electronic, mechanical,photocopying, or otherwise, without the prior written permission of the publisher, SASInstitute Inc.For a Web download or e-book: Your use of this publication shall be governed by theterms established by the vendor at the time you acquire this publication.U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of thissoftware and related documentation by the U.S. government is subject to the Agreementwith SAS Institute and the restrictions set forth in FAR 52.227–19 Commercial ComputerSoftware—Restricted Rights (June 1987).SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.1st electronic book, February 20091st printing, March 20092nd electronic book, September 20092nd printing, September 2009SAS® Publishing provides a complete selection of books and electronic products to helpcustomers use SAS software to its fullest potential. For more information about oure-books, e-learning products, CDs, and hard-copy books, visit the SAS Publishing Web siteat support.sas.com/publishing or call 1-800-727-3228.SAS® and all other SAS Institute Inc. product or service names are registered trademarksor trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USAregistration.Other brand and product names are registered trademarks or trademarks of theirrespective companies.

Page 3: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Contents

What’s New vii

Overview vii

Enhanced Support for the Wizards and the Procedures vii

Support for New File Formats vii

Date/Time Value Differences between SAS and Microsoft Files viii

Documentation Enhancements viii

P A R T 1 SAS/ACCESS 9.2 Interface to PC Files: Reference 1

Chapter 1 � Working with SAS/ACCESS Interface to PC Files Server 3Methods for Accessing PC Files Data 3

Using This Document 4

Sample Data in This Document 4

P A R T 2 Import and Export Wizards and Procedures 5

Chapter 2 � Supported Data Sources and Environments 7Reading and Writing Data Between SAS Data Sets and PC Files 7

Supported Data Sources and Environments 7

Chapter 3 � Using the SAS Import and Export Wizards 11Import and Export Wizards Overview 11

Using the External File Interface (EFI) 11

Chapter 4 � Using the IMPORT Procedure 13IMPORT Procedure Overview 13

Syntax: IMPORT Procedure 14

Chapter 5 � Using the EXPORT Procedure 19EXPORT Procedure Overview 19

Syntax: EXPORT Procedure 20

Chapter 6 � File Format-Specific Reference for the IMPORT and EXPORTProcedures 25Overview Delimited Files 26

Microsoft Excel Workbook Files 31

Importing and Exporting Microsoft Excel Files with the ACCESS and DBLOADProcedures 42

Microsoft Access Database Files 44

Lotus 1-2-3 WK n Files 53

dBase DBF Files 57

dBase DBFMEMO Files 62

JMP Files 62

Page 4: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

iv

Paradox DB File Formats 65

SPSS SAV Files 66

Stata DTA Files 68

P A R T 3 LIBNAME Statement and Pass-Through Facility on 32-Bit MicrosoftWindows 71

Chapter 7 � The LIBNAME Engines 73Overview: LIBNAME Engines 73

Software Requirements 74

Macro Variables 74

SAS Trace System Options 75

Chapter 8 � LIBNAME Statement: PC Files on Microsoft Windows 79LIBNAME Statement:PC Files on Microsoft Windows 79

LIBNAME Options 85

Data Set Options 92

Chapter 9 � The Pass-Through Facility for PC Files on Microsoft Windows 111LIBNAME Statement and Pass-Through Facility on Microsoft Windows 111

Syntax for the Pass-Through Facility for PC Files 112

Microsoft Jet and Microsoft Ace Provider Supported Data Types 121

Special Jet and Ace Queries 122

Special Jet Commands 124

Chapter 10 � File-Specific Reference 127Microsoft Excel Workbook Files 127

Microsoft Access Files 132

P A R T 4 LIBNAME Statement and Pass-Through Facility on Linux, UNIX, and64-Bit Microsoft Windows 137

Chapter 11 � PC Files Server Administration 139Overview 139

Windows Service 140

Desktop Application 141

Configuring PC Files Server 143

Authentication 144

PC Files Server Autostart 145

Local Security Policy Configuration 146

Constraints 147

Shared Information 147

Chapter 12 � LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit MicrosoftWindows 149LIBNAME Statement for PC Files on Linux, UNIX, and 64-Bit MicrosoftWindows 149

Page 5: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

v

SAS LIBNAME Options for PC Files on Linux and UNIX 156

Data Set Options for PC Files on Linux and UNIX, and 64-Bit Windows 162

Chapter 13 � Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit MicrosoftWindows 179Overview: Pass-Through Facility for PC Files on Linux, UNIX, and 64-Bit MicrosoftWindows 179

Syntax for the Pass-Through Facility for PC Files 180

Special PC Files Queries 190

P A R T 5 ACCESS and DBLOAD Procedures 193

Chapter 14 � The ACCESS Procedure for PC Files 195Overview: ACCESS Procedure for PC Files 195

SAS/ACCESS Descriptors for PC Files 197

SAS Passwords for Descriptors 197

Performance and Efficient View Descriptors for PC Files 198

ACCESS Procedure Syntax 198

Chapter 15 � The DBLOAD Procedure 219DBLOAD Procedure Overview 219

DBLOAD Procedure Naming Conventions 220

DBLOAD Procedure Syntax 220

Chapter 16 � File-Specific Reference for the ACCESS and DBLOAD Procedures 229ACCESS Procedure: XLS Specifics 229

DBLOAD Procedure: XLS Specifics 236

Setting Environment Variables for XLS Files 240

ACCESS Procedure: WKn Specifics 241

DBLOAD Procedure: WKn Specifics 244

Setting Environment Variables for WKn Files 247

ACCESS Procedure: DBF Specifics (Windows) 248

DBLOAD Procedure: DBF Specifics (Windows) 249

ACCESS Procedure: DIF Specifics 252

DBLOAD Procedure: DIF Specifics 255

Setting Environment Variables for DIF Files 257

P A R T 6 Appendixes 259

Appendix 1 � The DBF and DIF Procedures 261Introduction to the DBF and DIF Procedures 261

Appendix 2 � Recommended Reading 267Recommended Reading 267

Glossary 269

Index 275

Page 6: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

vi

Page 7: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

vii

What’s New

OverviewSAS/ACCESS 9.2 Interface to PC Files has these new features and enhancements:� support for running the PC Files Server as a Windows service� new PC Files Server authentication option� new PC Files Server autostart for Microsoft 64-bit Windows systems� support for Microsoft Excel 2007 and Microsoft 2007 Access files� support for UNICODE= LIBNAME option� support for FMTLIB option to support user-defined formats� support for new file formats� date and time value differences between SAS and Microsoft files� documentation enhancements for SAS/ACCESS Interface to PC Files

Enhanced Support for the Wizards and the ProceduresEnhanced PC-specific support is available for the IMPORT and EXPORT procedures,

as well as the Import and Export Wizards.For information that is specific to UNIX and OpenMVS for the IMPORT and

EXPORT procedures, see the Base SAS Procedures Guide.

Support for New File FormatsSAS import and export utilities support these file formats:� “dBase DBF Files” on page 57� “Lotus 1-2-3 WK n Files” on page 53� “Microsoft Access Database Files” on page 44� “Microsoft Excel Workbook Files” on page 31� “JMP Files” on page 62

Page 8: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

viii What’s New

� “Paradox DB File Formats” on page 65� “SPSS SAV Files” on page 66� “Stata DTA Files” on page 68

Date/Time Value Differences between SAS and Microsoft FilesIn different versions of SAS, the IMPORT procedure and the LIBNAME engine can

read in date and time values from a Microsoft Access databases and Microsoft Excelworkbooks using different formats.

For information about how to process date and time values, see “Processing Date andTime Values between SAS and Microsoft Excel” on page 131 and “Processing Date andTime Values between SAS and Microsoft Access” on page 136.

Documentation EnhancementsSAS/ACCESS 9.2 Interface to PC Files: Reference was significantly reorganized and

rewritten.

Page 9: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

1

P A R T1

SAS/ACCESS 9.2 Interface to PC Files:Reference

Chapter 1. . . . . . . . . .Working with SAS/ACCESS Interface to PC Files Server 3

Page 10: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

2

Page 11: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

3

C H A P T E R

1Working with SAS/ACCESSInterface to PC Files Server

Methods for Accessing PC Files Data 3Using This Document 4

Sample Data in This Document 4

Methods for Accessing PC Files DataYou can use SAS/ACCESS Interface to PC Files Server to read data from PC files for

use in SAS reports or applications. You can use SAS data sets to create PC files invarious formats. SAS/ACCESS Interface to PC Files includes accessing data inMicrosoft Access database files and Excel workbook files. The Import and ExportWizards guide you through the steps to access your data, see“Import and Export Wizards Overview” on page 11.

The Import and Export Wizards as well as the IMPORT and EXPORT proceduresfacilitate data transfer between SAS data sets and several PC file formats including:

� Microsoft Access� Microsoft Excel� Lotus 1-2-3� DBF� JMP� SPSS� Stata� Paradox

Not every PC file format is available under every operating environment. For a listof file formats that are supported in your operating environment, see “Supported DataSources and Environments” on page 7.

To use the LIBNAME statement to access PC files, you must install PC Files Server.See Chapter 8, “LIBNAME Statement: PC Files on Microsoft Windows,” on page 79.

To use the Pass-Through Facility, see “LIBNAME Statement and Pass-ThroughFacility on Microsoft Windows” on page 111.

See Chapter 14, “The ACCESS Procedure for PC Files,” on page 195. You can directlyread, update, or extract PC files data into a SAS data file. Use the ACCESS procedurewith Microsoft Excel 4, 5, 95, Lotus 1-2-3 (WK1, WK3, WK4), DBF, and DIF fileformats.

See Chapter 15, “The DBLOAD Procedure,” on page 219 for Windows operatingenvironments. The ACCESS procedure creates PC files, and loads them with the datafrom a SAS data set. Use the DBLOAD procedure with any file formats that theACCESS procedure supports. Both procedures are supported only for compatibility withSAS 6. Such SAS 6 limitations as the 8-character-long variable names apply.

Page 12: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

4 Using This Document � Chapter 1

“Introduction to the DBF and DIF Procedures” on page 261 for Linux, UNIX, andWindows. Covert formatted data between dBase (DBF) files and SAS data sets. Theprocedures also enable conversion between data interchange format (DIF) and SAS datasets.

Note: The DIF procedure is not available under IBM z/OS. �

Using This DocumentThis document is intended for applications programmers and users with these skills.� know how to use their operating environment� are familiar with their PC files� know how to use basic SAS commands and statements

This document provides a general reference, as well as specific details, and SAS codeexamples that show how to access and use data in PC files directly from within SAS.

Sample Data in This DocumentExamples in this document show how you can use SAS/ACCESS Interface to PC

Files to read and write PC file data directly from SAS programs. They are not meant asexamples for you to follow in designing files for any purpose. Sample data is availablefrom http://supporttest.unx.sas.com/kb/##/###.html. The data is based on a fictitiousinternational textile manufacturer whose product line includes some special fabrics thatthey make to precise specifications. All data is fictitious.

Page 13: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

5

P A R T2

Import and Export Wizards and Procedures

Chapter 2. . . . . . . . . .Supported Data Sources and Environments 7

Chapter 3. . . . . . . . . .Using the SAS Import and Export Wizards 11

Chapter 4. . . . . . . . . .Using the IMPORT Procedure 13

Chapter 5. . . . . . . . . .Using the EXPORT Procedure 19

Chapter 6. . . . . . . . . .File Format-Specific Reference for the IMPORT and EXPORTProcedures 25

Page 14: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

6

Page 15: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

7

C H A P T E R

2Supported Data Sources andEnvironments

Reading and Writing Data Between SAS Data Sets and PC Files 7Supported Data Sources and Environments 7

Reading and Writing Data Between SAS Data Sets and PC Files

To read and write data between SAS data sets and external PC files, you can use the“IMPORT Procedure Overview” on page 13, the “EXPORT Procedure Overview” on page19, as well as the Chapter 3, “Using the SAS Import and Export Wizards,” on page 11.

Although procedures provide similar capabilities, the wizards have a user interface.The procedures are code-based and support additional features. For example, youcannot use the wizards to specify such data set options as DROP, KEEP, and WHERE.

Supported Data Sources and EnvironmentsThe IMPORT and EXPORT procedures work within the limited range of available PC

file formats if they reside locally on UNIX. The procedures work with a wider range ofPC file formats if they reside locally on a PC.

The Import and Export Wizards and the IMPORT and EXPORT procedures are partof Base SAS software. If SAS/ACCESS Interface to PC files is not licensed, access islimited to CSV, TXT, and delimited files.

Alternate methods to access data are described in “Methods for Accessing PC FilesData” on page 3.

Note: The PC File Server version MUST match the SAS version. �

Page 16: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

8 Supported Data Sources and Environments � Chapter 2

Table 2.1 Supported Data Sources and Platforms for the IMPORT and EXPORT Procedures and theImport and Export Wizards

Import ExportData Source Description

DataSource

Identifier Wizard PROC Wizard PROC

SupportedPlatforms

Supported SASPlatforms by

Release

Excel using a LIBNAMEengine

EXCEL

EXCEL97

EXCEL2000

EXCEL2002

EXCEL2003

EXCEL2007

Yes Yes Yes Yes32-bit

Windows9.0 or higher

Excel using PC FilesServer

EXCELCS No Yes No Yes

64-bitWindows

Linux, UNIX

9.1.3 or higher

9.1 or higher

Excel using .xls fileformats

XLS No Yes No Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.1.3 SP3 orhigher

Excel 4 using PROCACCESS and PROCDBLOAD

EXCEL 4 Yes Yes Yes Yes

32-bitWindows

64-bitWindows

8.2 or higher

9.1.3 SP1 orhigher

Excel 5 using PROCACCESS and PROCDBLOAD

EXCEL 5 Yes Yes Yes Yes

32-bitWindows

64-bitWindows

8.2 or higher

9.1.3 SP1 orhigher

Access 2000 usingLIBNAME engine

ACCESS

ACCESS2000

ACCESS2002

ACCESS2003

ACCESS2007

Yes Yes Yes Yes32-bit

Windows9.0 or higher

Access 97 usingLIBNAME engine

ACCESS97

Yes Yes Yes Yes32-bit

WindowsV9.0 or higher

Access using PC FilesServer

ACCESSCS No Yes No Yes

64-bitWindows

Linux, UNIX

9.1.3 or higher

9.1 or higher

Page 17: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Supported Data Sources and Environments � Supported Data Sources and Environments 9

Import ExportData Source Description

DataSource

Identifier Wizard PROC Wizard PROC

SupportedPlatforms

Supported SASPlatforms by

Release

dBase using .DBF fileformats

DBF Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

8.2 or higher

9.1.3 SP1 orhigher

8.1 or higher

dBase file formats withMEMO support

DBFMEMO No Yes No Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.2

JMP using .JMP fileformats

JMP Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.1 or higher

9.1.3 or higher

9.1 or higher

Paradox using .DB fileformats

DB Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.2

SPSS using .SAV fileformats

SAV Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.1.3 SP3 orhigher

Stata using .DTA fileformats

DTA Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

9.1.3 SP3 orhigher

Lotus 1-2-3 using .WK1file formats

WK1 Yes Yes Yes Yes

32-bitWindows

64-bitWindows

8.2 or higher

9.1.3 or higher

Lotus 1-2-3 using .WK3file formats

WK3 Yes Yes Yes Yes

32-bitWindows

64-bitWindows

8.2 or higher

9.1.3 or higher

Lotus 1-2-3 using .WK4file formats

WK4 Yes Yes Yes Yes

32-bitWindows

64-bitWindows

8.2 or higher

9.1.3 or higher

Page 18: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

10 Supported Data Sources and Environments � Chapter 2

Import ExportData Source Description

DataSource

Identifier Wizard PROC Wizard PROC

SupportedPlatforms

Supported SASPlatforms by

Release

comma-separated file CSV Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

Open VMS

8.2 or higher

tab-separated file TAB Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

Open VMS

8.2 or higher

delimiter-separated file DLM Yes Yes Yes Yes

32-bitWindows

64-bitWindows

Linux, UNIX

Open VMS

V8.2 or higher

data files using client/server model

PCFS No Yes No Yes

64-bitWindows

Linux, UNIX

9.1 or higher

Page 19: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

11

C H A P T E R

3Using the SAS Import and ExportWizards

Import and Export Wizards Overview 11Importing and Exporting Data with the Wizards 11

Using the External File Interface (EFI) 11

Import and Export Wizards Overview

Importing and Exporting Data with the WizardsWith the Import and Export Wizards you can transfer data between external data

sources and SAS Data sets. As each wizard presents a series of windows with simplechoices to guide you through a process, making a complex or infrequent task moresimple to perform.

� The Import Wizard guides you through the steps to read data from an externaldata source and write it to a SAS data set.

� The Export Wizard guides you through the steps to read data from a SAS data setand write it to an external data source.

You can request that the wizard generate the procedure statements, which you cansave to a file for subsequent use. For each step, each wizard displays a window withavailable selections. To get help for any window or window item, select Help.

To start either wizard, select File � Import Data or File � Export Data.

Using the External File Interface (EFI)

The External File Interface (EFI) is a graphical user interface that enables you toread and write data that is not in a SAS internal format.

After a series of windows that request specific information, the wizard invokes theEFI when you select Finish. To return to the wizard without invoking the EFI, selectBack. To close the wizard without invoking the EFI, select Cancel.

For instructions about using the EFI, select Help � Using This Window.

Page 20: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

12

Page 21: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

13

C H A P T E R

4Using the IMPORT Procedure

IMPORT Procedure Overview 13Syntax: IMPORT Procedure 14

PROC IMPORT Statement 14

IMPORT Procedure Overview

The IMPORT procedure reads data from an external data source and writes it to aSAS data set. External data sources can include:

� Microsoft Access databases

� Microsoft Excel workbooks

� Lotus 1-2-3 spreadsheets

� Paradox files

� SPSS files

� Stata files

� DBF files

� JMP delimited files

Delimited files contain columns of data values that are separated by a delimiter, suchas a blank or a comma.

The SAS variable definitions are based on the input records. The IMPORT procedureimports the data using one of the following methods:

� generated DATA step code

� generated SAS/ACCESS code

� translation engines.

You customize the results with statements and options that are specific to the inputdata source. The Import procedure generates a SAS data set and writes informationabout the import to the SAS log. In the log, you see the DATA step, or theSAS/ACCESS code that the Import procedure generates. If a translation engine is used,no code is submitted.

To import data, you can use the Import Wizard, which is a windowing tool thatguides you through the steps to import an external data source. You can request thatthe Import Wizard generate IMPORT procedure statements, which you can save forsubsequent use. To open the Import Wizard, select File � Import Data from the SASwindowing environment.

Page 22: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

14 Syntax: IMPORT Procedure � Chapter 4

Syntax: IMPORT Procedure

PROC IMPORTDATAFILE="filename"|DATATABLE="tablename"OUT=<libref.>SAS data-set <(SAS data-set-options)><DBMS=data-source-identifier><REPLACE> ;

<data-source-statement(s);>

PROC IMPORT StatementSupport: The IMPORT procedure is available for these operating environments:

� Linux, UNIX

� Microsoft Windows

PROC IMPORTDATAFILE="filename"OUT=<libref.>SAS-data-set<DBMS=data-source-identifier><REPLACE> ;

Required Arguments

DATAFILE="file-name"specifies the complete path and filename or fileref for the input file. A fileref is a SASname that is associated with the physical location of the output file. To assign afileref, use the FILENAME= statement. You can omit the quotation marks if thefile-name does not include certain characters such as these:

� backslash

� lowercase characters

� spaces

Alias: FILE

See also: The FILENAME statement in SAS Language Reference: Dictionary

Restriction: The IMPORT procedure does not support device types or accessmethods for the FILENAME statement except for DISK. For example, theIMPORT procedure does not support the TEMP device type, which creates atemporary external file.

Restriction: For client server applications. When running SAS/ACCESS on UNIX,to access data stored on a PC server, you must specify the full path and filenameof the import file. The use of a fileref is not supported.

Restriction: The IMPORT procedure can import data if the data type is supportedby SAS. SAS supports numeric and character types of data but not (for example,binary objects). If the data that you want to import is a type that SAS does notsupport, the IMPORT procedure might not import it correctly. In many cases, theprocedure attempts to convert the data to the best of its ability. However, at timesthis is not possible.

Page 23: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Using the IMPORT Procedure � PROC IMPORT Statement 15

Interaction: For some input data sources such as a Microsoft Excel spreadsheet,the first eight rows of data are scanned. The most prevalent data type (numeric orcharacter) is used for a column. This is the default. If most of the data in the firsteight rows is missing:

� SAS defaults to data type: character� any subsequent numeric data for that column is set to missing.

If most of the data in the first eight rows is character data:� SAS assigns data type: character� any subsequent numeric data for that column is set to missing.

Default: characterNote: For information about how SAS converts data types, see the specific

information for the data source file format that you are importing.Note: To import DBF files created with Microsoft Visual FoxPro, you must export to

an appropriate dBASE format using Visual Fox PRO. Import the dBASE file toSAS.

DATATABLE="table-name"specifies the table name of the input DBMS table. If the name does not includespecial characters, such as question marks, lowercase characters, or spaces, you canomit the quotation marks. The DBMS table name might be case sensitive.Alias: TABLERequirement: When importing Microsoft Access tables, SAS/ACCESS converts the

table name to a SAS member name. SAS does not support member names longerthan 32 bytes.

Requirement: When you import a DBMS table, you must specify the DBMS=option.

OUT=<libref.>SAS-data-setidentifies the output SAS data set with either a one- or two-level SAS name (libraryand member name). If the specified SAS data set does not exist, The IMPORTprocedure creates it. If you specify a one-level name, by default the IMPORTprocedure uses either the SASUSER library if assigned, or the WORK library ifSASUSER not assigned.Featured in: All examples.

(SAS data-set-options)specifies SAS data set options. For example, to assign a password to the resultingSAS data set, you can use the ALTER= , PW= , READ= , or WRITE= data setoptions. To import only data that meets a specified condition, you can use theWHERE data set option.

For information about all SAS data set options, see the data set options section inSAS Language Reference: Dictionary.

Statement Options

DBMS=data-source-identifierspecifies the type of data to import. To import a DBMS table, you must specify DBMS= using a valid database identifier; DBMS=ACCESS specifies to import a MicrosoftAccess 2000, 2002, or 2003 table. Only specify the DBMS= option to import files, ifDATAFILE contains an extension that the IMPORT procedure cannot recognize.

For example, the IMPORT procedure recognizes the filename ACCOUNTS.WK1 asa Lotus 1-2-3 Release 2 spreadsheet and the filename MYDATA.CSV as a delimited

Page 24: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

16 PROC IMPORT Statement � Chapter 4

external file that contains comma-separated data values. Therefore, a DBMS=specification is not necessary.

The following values are valid for the DBMS= option. For detailed informationabout supported data sources and environments, see “Supported Data Sources andEnvironments” on page 7. For information about accessing PC Files Data, see“Methods for Accessing PC Files Data” on page 3.

DataSource

IdentifierInput Data Source Extension

Access Microsoft Access 2000, 2002, 2003, or 2007 table (using the LIBNAMEstatement)

.mdb

.accdb

Access97 Access 97 table (using the LIBNAME statement) .mdb

Accesscs Access table (using the LIBNAME statement) .mdb

.accdb

CSV Delimited file (comma-separated values) .csv

DBF dBASE 5.0, IV, III+, and III files .dbf

dbfMemo dBASE 5.0, IV, III+, and III files with memos

FoxPro and Visual FoxPro files with memos

.dbf

.fpt

.dbt

DLM Delimited file (default delimiter is a blank) .*

DTA Stata file .dta

Excel Excel 97, 2000,or 2002 spreadsheet (using the LIBNAME statement) .xls

.xlsb

.xlsm

.xlsx

Excel 4 Excel 4.0 spreadsheet (using PROC ACCESS) .xls

Excel 5 Excel 5.0 or 7.0 (95) spreadsheet (using PROC ACCESS) .xls

Excelcs Excel spreadsheet (using the LIBNAME statement) .xls,.xlsb

jmp JMP Files

Paradox Paradox .DB files .db

PCFS PC Files Server .jmp

SAV SPSS file .sav

TAB delimited file (tab-delimited values) .txt

WK1 Lotus1-2-3 Release 2 spreadsheet .wk1

WK3 Lotus 1-2-3 Release 3 spreadsheet .wk3

WK4 Lotus 1-2-3 Release 4 or 5 spreadsheet .wk4

XLS Excel 5.0, 95, 97, 2000, 2002, or 2003 spreadsheet (using file formats) .xls

Restriction: The availability of a data source depends on:

Page 25: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Using the IMPORT Procedure � PROC IMPORT Statement 17

� The operating environment and in some cases the platform.

� Whether your site has a SAS/ACCESS Interface for PC Files license. If yoursite does not have a license, only delimited files are supported.

When you specify a value for DBMS= consider the following:

� When you specify DBMS=XLS for an Excel file, you can read and write Excelspreadsheets under UNIX directly, without having to access the PC Files Server.

� Microsoft Access versions 2000, 2002, and 2003 share the same internal fileformats. The SAS LIBNAME engine recognizes ACCESS 2000, ACCESS 2002,ACCESS 2003, and ACCESS 2007 as aliases for the identifier ACCESS. Byspecifying DBMS=ACCESS, SAS can read any of these versions of files that aresaved in Microsoft Access applications.

� Microsoft Excel versions 97, 2000, 2002, and 2003 share the same internal fileformats. The SAS LIBNAME engine recognizes EXCEL 97, Excel 2000, Excel2002, Excel 2003, and Excel 2007 as aliases for the identifier Excel.

This table summarizes the versions of Excel files and whether the IMPORTprocedure can distinguish among them based on the DBMS= specification.

Table 4.1 Excel Spreadsheet Specification Compatibility

Identifier Excel 2007 Excel 97, 2000,2002, 2003

Excel 5.0, 95 Excel 4.0

XLS no yes yes no

EXCEL yes yes yes yes

EXCEL5 no no yes yes

EXCEL4 no no yes yes

This table summarizes the access technology used based on the DBMSspecifications.

DBMS= Uses Requires OperatingPlatform

Excel SAS Excel LIBNAME engine Microsoft Jet or AceProvider

32-bit Windows

xls File formats technology 32-bit Windows

64-bit Windows

Linux, UNIX

Excelcs PC Files LIBNAME engine PC Files Server, ExcelDriver on 32-bit Windows

64-bit Windows,

Linux, UNIX

Note: Although Excel 4.0 and Excel 5.0 spreadsheets are often interchangeable, it isrecommended that you specify the exact version.

REPLACEoverwrites an existing SAS data set. If you do not specify REPLACE, the IMPORTprocedure does not overwrite an existing data set.

Page 26: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

18

Page 27: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

19

C H A P T E R

5Using the EXPORT Procedure

EXPORT Procedure Overview 19Syntax: EXPORT Procedure 20

PROC EXPORT Statement 20

EXPORT Procedure Overview

The EXPORT procedure reads data from a SAS data set and writes it to an externaldata source. External data sources can include:

� Microsoft Access databases

� Microsoft Excel workbooks

� Lotus 1–2–3 spreadsheets

� Paradox files

� SPSS files

� Stata files

� DBF files

� JMP delimited files

Delimited files contain columns of data values, that are separated by a delimiter, suchas a blank or a comma.

The EXPORT procedure reads the input file and writes the data to an external datasource. The EXPORT procedure exports the data using one of these methods:

� generated DATA step code

� generated SAS/ACCESS code

� translation engines

You customize the results with statements and options that are specific to the outputdata source. The EXPORT procedure generates the specified output file and writesinformation about the export to the SAS log. In the log, you see the DATA step or theSAS/ACCESS code that the EXPORT procedure generates. If a translation engine isused, no code is submitted.

To export data, you can also use the Export Wizard, which is a windowing tool thatguides you through the steps to export to an external data source. You can request thatthe Export Wizard generate EXPORT procedure statements, which you can save forsubsequent use. To open the Export Wizard, select File � EXPORT Data from the SASwindowing environment.

Page 28: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

20 Syntax: EXPORT Procedure � Chapter 5

Syntax: EXPORT ProcedureSupport: The EXPORT procedure is available for these operating environments:

� Linux, UNIX

� Microsoft Windows

PROC EXPORT DATA=<libref.>SAS data-set <(SAS-data-set-options)>OUTFILE="filename" | OUTTABLE="tablename"<DBMS=data-source-identifier> <REPLACE> <LABEL>;

<data-source-statement(s);>

PROC EXPORT Statement

PROC EXPORT DATA=<libref.>SAS data-set <(SAS data-set-options)>OUTFILE="filename" | OUTTABLE="tablename"<DBMS=data-source-identifier> <REPLACE> <LABEL>;

Required Arguments

DATA=<libref.>SAS data-setidentifies the input SAS data set with either a one- or two-level SAS name (libraryand member name). If you specify a one-level name, by default, the EXPORTprocedure uses either the SASUSER library (if assigned) or the WORK library (ifUSER not assigned).

Default: If you do not specify a SAS data set, the EXPORT procedure uses the mostrecently created SAS data set, which SAS keeps track of with the system variable_LAST_. However, in order to be certain that the EXPORT procedure uses thecorrect data set, you should identify the SAS data set.

Restriction: The EXPORT procedure can export data only if the format of the datais supported by the data source or the amount of data is within the limitations ofthe data source. For example, some data sources have a maximum number of rowsor columns, and some data sources cannot support SAS user-defined formats andinformats. If the data that you want to export exceeds the limits of the datasource, the EXPORT procedure might not be able to export it correctly. When SASencounters incompatible formats, the procedure formats the data to the best of itsability.

(SAS data-set-options)specifies SAS data set options. For example, if the data set that you are exportinghas an assigned password, you can use the ALTER= option, the PW= option, theREAD= option, or the WRITE= option. To export only data that meets a specifiedcondition, you can use the WHERE= data set option. For information about SASdata set options, see “Data Set Options” in SAS Language Reference: Dictionary.

OUTFILE="filename"

Page 29: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Using the EXPORT Procedure � PROC EXPORT Statement 21

specifies the complete path and filename, or a fileref for the output PC file,spreadsheet, or delimited external file. You can omit the quotation marks you specifya fileref or if the complete path and filename do not include special characters (suchas the backslash in a path), lowercase characters, or spaces. A fileref is a SAS namethat is associated with the physical location of the output file. To assign a fileref, usethe FILENAME statement.Alias: FILERestriction: The EXPORT procedure does not support device types or access

methods for the FILENAME statement except for DISK. For example, theEXPORT procedure does not support the TEMP device type, which creates atemporary external file.

Restriction: For client server applications: You must specify the full path andfilename of the file that you want to import when you are running SAS/ACCESSsoftware on UNIX to access data that is stored on a PC server. Using a fileref isnot supported.

OUTTABLE="table-name"specifies the table name of the output DBMS table. If the name does not includespecial characters (such as question marks), lowercase characters, or spaces, you canomit the quotation marks. The DBMS table name might be case sensitive.Alias: TABLERequirement: When you export a DBMS table, you must specify the DBMS= option.

Statement OptionsWhen exporting data to a Microsoft Access table, SAS/ACCESS Interface for PC Files

converts the table name to a SAS member name. SAS does not support member namesthat are longer than 32 bytes.

DBMS=data-source-identifierspecifies the type of data to export. To export a DBMS table, you must specifyDBMS= by using a valid database identifier. For example, DBMS=ACCESS specifiesto export a table into a Microsoft Access 2000, 2002, 2003, or 2007 database. You donot have to specify DBMS= to EXPORT PC files, spreadsheets, and delimitedexternal files if the filename that you specify in OUTFILE= contains a validextension. The EXPORT procedure can recognize the type of data if you specify avalid extension. For example, the EXPORT procedure recognizes the filenameACCOUNTS.WK1 as a Lotus 1-2-3 Release 2 spreadsheet and the filenameMYDATA.CSV as an external file that contains comma-separated data values.Therefore, a DBMS= specification is not necessary.Note: When you specify DBMS=XLS for an Excel file, you can read and write Excel

spreadsheets under UNIX directly, without having to access the PC Files Server.The following values are valid for the DBMS= option. For detailed information

about supported platforms and SAS releases, see Chapter 6, “File Format-SpecificReference for the IMPORT and EXPORT Procedures,” on page 25.

Data SourceIdentifier

Output Data Source ExtensionVersionof FileCreated

ACCESS*Microsoft Access 2000, 2002, 2003 or 2007 table

(using the LIBNAME statement)

.mdb

.accdb

2000

2007

ACCESS97Microsoft Access 97 table (using the LIBNAME

statement).mdb 97

Page 30: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

22 PROC EXPORT Statement � Chapter 5

Data SourceIdentifier

Output Data Source ExtensionVersionof FileCreated

ACCESSCSMicrosoft Access table (using the LIBNAME

statement)

.mdb

.accdb

2000***

2007

CSV delimited file (comma-separated values) .csv

DBF dBASE 5.0, IV, III+, and III files .dbf 5.0

DBFMEMOdBASE 5.0, IV, III+, and III files with memos

FoxPro and VisualPro with memos

.dbf

.fpt5.0

DLM delimited file (default delimiter is a blank) .*

DTA Stata file .dtaVersion

8

EXCEL4 Excel 4.0 spreadsheet (using proc DBLOAD) .xls 4.0

EXCEL5Excel 5.0 or 7.0 (95) spreadsheet (using proc

DBLOAD).xls 5.0

EXCEL*Excel 97, 2000, 2002, 2003 or 2007 spreadsheet

(using the LIBNAME statement)

.xls

.xlsb

.xlsx

97

2007

2007

EXCELCS Excel spreadsheet (using the LIBNAME statement).xls

.xlsb

97**

2007

XLSExcel 97, 2000, 2002, or 2003 spreadsheet (using file

formats).xls 97

JMP JMP file .jmp

PARADOX Paradox DB files .db

PCFS JMP files .jmp

SAV SPSS file, compressed and uncompressed binary files .sav

TAB delimited file (tab-delimited values) .txt

WK1 Lotus 1-2-3 Release 2 spreadsheet .wk1

WK3 Lotus 1-2-3 Release 3 spreadsheet .wk3

WK4 Lotus 1-2-3 Release 4 and 5 spreadsheet .wk4

* Not available for Microsoft Windows 64-Bit edition.** Value listed is the default value. The real version of the loaded file depends on theversion of the existing file, or the value that you specified for VERSION= option.

Restriction: The availability of an output data source depends on:

� the operating environment, and in some cases the platform, as specified inthe previous table.

� whether your site has a license to SAS/ACCESS Interface for PC Files. If youdo not have a license, only delimited files are available.

When you specify a value for DBMS=, consider the following for specific datasources:

Page 31: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Using the EXPORT Procedure � PROC EXPORT Statement 23

� Microsoft Access 2000, 2002, and 2003 share the same internal file formats. TheSAS LIBNAME engine recognizes ACCESS2000, ACCESS2002, ACCESS2003,and ACCESS2007 as aliases for the identifier ACCESS. The SAS export file canbe read by any of these versions of Microsoft Access.

� Microsoft Excel 97, 2000, 2002, and 2003 share the same internal file formats.The SAS LIBNAME engine recognizes EXCEL97, EXCEL2000, EXCEL2002,EXCEL2003, and EXCEL2007 as aliases for the identifier EXCEL. The SASexport file can be read by any of these versions of Microsoft Excel.

� To export a data set to an existing Microsoft Access database, the EXPORTprocedure can write to Access 97, Access 2000, Access 2002, or Access 2003regardless of your specification. For example, if you specifyDBMS=ACCESS2000 and the database is in Access 97 format, the EXPORTprocedure exports the table, and the database remains in Access 97 format.

However, if you specify a DATABASE= option for an Access database .mdbfile that does not exist, a new database is created using the format specified inthe DBMS= option. For example, if you specify DBMS=ACCESS to create a newfile, the result is an MDB file that Access 2000, 2002, or 2003 can read, butAccess 97 cannot. For more information about the DATABASE= option, seeMicrosoft Access Database Files.

. The following table summarizes the DBMS= option specifications andindicates which version of Microsoft Access can access the resulting database.

Identifier Access 2007Access 2000, 2002,

2003Access 97

ACCESS yes yes no

ACCESS 97 yes yes yes

ACCESS 2007

Restriction: Only Access 2007 and above can open Access 2007 file formats.

Feature: Access 2007 can open all previous formats.

� To export a Microsoft Excel spreadsheet, the EXPORT procedure creates an XLSfile for the specified version. This table summarizes the DBMS= specificationsand indicates which version of Microsoft Excel can open the resultingspreadsheet:

Identifier Excel 2007Excel 97, 2000,

2002, 2003Excel 5.0,

95Excel 4.0

XLS yes yes no no

EXCEL yes yes no no

EXCEL 5 yes yes yes no

EXCEL 4 yes yes yes yes

� Missing values are translated to blanks when you export a SAS data set to adBASE file (DBF) if the data set does not contain character or numeric values.

Page 32: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

24 PROC EXPORT Statement � Chapter 5

� Due to dBASE limitations, values for a character variable that are longer than256 characters are truncated in the resulting dBASE file when you export aSAS data set to a dBASE file (DBF).

Microsoft Excel

Restriction: Only Excel 2007 and above can open Excel 2007 formats.Feature: Excel 2007 can open all previous formats. Later versions of Excel can

open and update files in previous formats.

REPLACEoverwrites an existing file. For a Microsoft Access database or an Excel workbook,REPLACE overwrites the target table or spreadsheet. If you do not specifyREPLACE, the EXPORT procedure does not overwrite an existing file.

LABELwrites SAS label names as column names to the exported table. If SAS label namesdo not exist, then the variable names are used as column names in the exported table.

Alias: DBLABELRequirement: When you export a DBMS table, you must specify the DBMS= option.

Page 33: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

25

C H A P T E R

6File Format-Specific Referencefor the IMPORT and EXPORTProcedures

Overview Delimited Files 26CSV Files 27

Tab Delimited File 27

Other Delimiters 27

External File Interface (EFI) 27

Summary of Supported Import and Export Procedure Options 28Details of Supported IMPORT and EXPORT Statements Options 28

Examples of Importing and Exporting Delimited File Types 30

Example 1. Import a TAB Delimited File into SAS 30

Example 2. Import a Space Delimited File into SAS 30

Example 3. Export a SAS Data Set to a CSV File 30

Example 4. Import a Subset of a CSV File into SAS 30Microsoft Excel Workbook Files 31

Overview of Microsoft Excel Files Essentials 31

Excel Data Types 32

Excel Numeric Data and Time Values 33

Excel File Formats 33SAS Import and Export Utilities Support for Excel Files 33

LIBNAME Statement Options to Import or Export Excel Data 34

IMPORT and EXPORT Procedure Options for Excel Files 35

Example 1: Export a SAS Data Set to an Excel File 41

Example 2: Import a Range from Excel 2007 File to a SAS Data Set 41Example 3: Import a Range From an Excel File on a PC Files Server to a SAS Data Set 41

Example 4: Export a SAS Data Set to an Excel Workbook File 42

Example 5: The IMPORT Procedure Using SSPI - Microsoft 64–bit Windows 42

Importing and Exporting Microsoft Excel Files with the ACCESS and DBLOAD Procedures 42

ACCESS and DBLOAD Procedures Options 43

Example 1: Export SAS Data Sets to Excel Workbook Files 43Example 2: Import Data Using a Range Name 44

Example 3: Import Data Using an Absolute Range Address 44

Microsoft Access Database Files 44

Microsoft Access File Essentials 44

Microsoft Access Data Types 45The Conversion of Date and Time Values between SAS Data Sets and Microsoft Access

Database 46

The IMPORT and EXPORT Procedure Statements for Access Files 46

Example 1: Import a SAS Data Set from an Access 2007 Database Table 52

Example 2: Export a SAS Data Set and Create an Access Database File 52Example 3: Import a Data Set from an Access Database File Using a Read Buffer 52

Example 4: Export a SAS Data Set to an Access Database File on a PC Files Server 52

Lotus 1-2-3 WK n Files 53

Page 34: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

26 Overview Delimited Files � Chapter 6

WK n Files Essentials 53WKn Data Types 54

Supported Import and Export Components and Statements for WK n Files 55

Example 1: Export a SAS Data Set to a WK4 File 56

Example 2: Import Data from a SAS Data Set from a WK4 File 56

Example 3: Export Data to a WK1 File from a SAS Data Set 57Example 4: Import Data from a WK1 File into a SAS Data Set 57

dBase DBF Files 57

DBF Files Essentials 57

DBF Data Types 58

Setting Environment Variables and System Options 59

Supported SAS IMPORT and EXPORT Procedure Statements 60Example 1: Export Data to a DBF File from a SAS Data Set 61

Example 2: Import Data from a DBF File into a SAS Data Set 61

Example 3: Export Data to a DBF File from a SAS Data Set Using Encoding 61

Example 4: Import and Translate Data from a DBF File 61

dBase DBFMEMO Files 62Overview 62

Example 1: Import Data from a DBF File with Memo Field into a SAS Data Set 62

JMP Files 62

JMP Files Essentials 62

JMP Missing Values 62JMP Data Types 63

Importing and Exporting Data in JMP Files 64

Supported Syntax by the IMPORT Procedure and the EXPORT Procedure 64

Example 1: EXPORT a SAS Data Set to a JMP File 64

Example 2: IMPORT a SAS Data Set from a JMP File 65

Example 3: EXPORT a SAS Data Set on UNIX to a JMP File on Microsoft Windows 65Example 4: IMPORT Data from a JMP File on Microsoft Windows to a SAS Data Set on

UNIX 65

Paradox DB File Formats 65

Paradox File Essentials 66

Example 1: EXPORT a SAS Data Set to a Paradox DB File 66Example 2: IMPORT a SAS Data Set from a Paradox DB File 66

SPSS SAV Files 66

SAV File Essentials 66

SPSS Data Types 66

Example 1: EXPORT a SAS Data Set to an SPSS SAV File 68Example 2: IMPORT a SAS Data Set from an SPSS SAV File 68

Stata DTA Files 68

DTA Files Essentials 68

DTA Data Types 68

Example 1: EXPORT a SAS Data Set to a Stata DTA File 70

Example 2: IMPORT a SAS Data Set from a Stata DTA File 70

Overview Delimited Files

In computer programming, a delimited text file is a file in which the individual datavalues contain embedded delimiters, such as quotation marks, commas, and tabs. Adelimiter is a character that separates words or phrases in a text string that defines thebeginning or end of a contiguous string of character data.

� the delimiter is not considered part of the character data string

Page 35: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � External File Interface (EFI) 27

� the first row of data is usually read as column headings� the column headings are then converted to SAS variable names� a line character indicates a new row

A delimited text file is also called a delimiter-separated values file (DSV or DSM).

CSV FilesA comma-separated values file, is a form of a delimited file. The data values are

separated by commas. A file where each line can represent

� an entry� a record

� a row� an observation in a database management system

� other applications

First,Last,AgeAbraham,Howard,31Smith,Jack,24Chen,Jo,38;

Tab Delimited FileA TAB delimited file is a form of delimited file where the delimiter is a tab character.

The values form columns of a database table, that can be exported to a database table.Control characters that represent the tab key separate the values.

Other DelimitersFiles that have other delimiters such as spaces ( ) or semicolons, are also known as

delimited text files or delimited files.

External File Interface (EFI)EFI

The SAS Import and Export Wizards use the SAS External File Interfacecomponents to read and write data in delimited external files.

The delimited file component is included in Base SAS and does not require alicense for SAS/ACCESS Interface to PC Files. Be aware of these behaviors whenusing these wizards and procedures to import or export data in a delimitedexternal file.

� When data values are enclosed in quotation marks, delimiters within thevalue are treated as character data. Quotation marks are removed fromcharacter values.

� Two consecutive delimiters indicate a missing value.� A delimiter can be specified as one or more characters.

� While exporting data, the EXPORT procedure discards items that exceed theoutput line length.

Page 36: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

28 Summary of Supported Import and Export Procedure Options � Chapter 6

� The delimiter can be in binary form. Example: delimiter=’09’X.� As the IMPORT procedure reaches the end of the current input data row,

variables without any values are set to missing.

See the DROPOVER= option in the FILE statement in the SAS Language Reference:Dictionary.

Featured in:� Chapter 3, “Using the SAS Import and Export Wizards,” on page 11.� Chapter 4, “Using the IMPORT Procedure,” on page 13.� Chapter 5, “Using the EXPORT Procedure,” on page 19.� “Using the External File Interface (EFI)” on page 11.

Summary of Supported Import and Export Procedure OptionsDelimited Files

This table lists the availability of the IMPORT and EXPORT procedure statementsand options. The supported file types are CSV (comma delimited values), TAB(tab-separated values), and DLM (delimiter separated values). There arealternatives to accessing delimited PC files formats under Linux and UNIX.Currently, Windows, UNIX, and VMS can access delimited files.See: “Example 1. Import a TAB Delimited File into SAS” on page 30.

Table 6.1 Summary of Supported IMPORT and EXPORT Procedure Statements

DelimitedFileType

StatementOptions

PROCImport

PROCExport

Valid ValueDefaultValue

DATAROW= Yes No 1 to 2147483647 2

GETNAMES= Yes No Yes | No Yes

GUESSINGROWS= Yes No 1 to 2147483647 20

CSV andTAB

PUTNAMES= No Yes Yes|No Yes

DATAROW= Yes No 1 to 2147483647 2

DELIMITER= Yes Yes ’char’ | ’nn’x ’ ’

GETNAMES= Yes No Yes|No Yes

GUESSINGROWS= Yes No 1 to 2147483647 20

DLM

PUTNAMES= No Yes Yes | No Yes

Details of Supported IMPORT and EXPORT Statements OptionsDATAROW

specifies the row number where the IMPORT procedure starts reading data.Default: 2Valid Values: 1 to 2147483647Restriction: If GETNAMES=Yes, then DATAROW=number ge 2Restriction: If GETNAMES=No, then DATAROW= 1

DELIMITER=’char’| ’nn’x

Page 37: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Details of Supported IMPORT and EXPORT Statements Options 29

specifies the delimiter that separates the columns of data for the IMPORT andEXPORT procedures.Default: Blank character.Restriction: For DLM and DSV files only.Restriction: If you do not specify a DELIMITER value, the default value (a

blank character) is used as the delimiter.Note: You can specify the delimiter as a single character or as a hexadecimal

value. For example, if columns of data are separated by an ampersand, specifyDELIMITER=’&’.

GETNAMES=YES|NOspecifies whether the IMPORT procedure is to generate SAS variable names fromthe data values in the first row of the import file.

If data in the first row of the input file contains special characters for a SASvariable name, such as a blank; SAS converts the character to an underscore. Forexample, the column heading.

YES specifies that the IMPORT procedure generate SAS variablenames from the data values in the first row of the importedExcel file.

NO specifies that the IMPORT procedure generate SAS variablenames as F1, F2, F3, and so on.

Default: YesRestriction: Valid only for Windows.Restriction: Valid only for the IMPORT procedure.Restriction: Supported only when DBMS=EXCEL.Restriction: When SAS reads the data value in the first row of the input file,

SAS checks for invalid SAS name characters (such as a blank). Invalidcharacters are converted to an underscore. For example, the data valueOccupancy Code becomes the SAS variable name Occupancy_Code.

GUESSINGROWS=1 to 2147483647specifies that number of rows that the IMPORT procedure is to scan to determinethe appropriate data type for the columns. The scan process scans from row 1 tothe row number that is specified by GUESSINGROWS= option.Default: 20Note: The default row number can be changed in the SAS REGISTRY as follows:

From the SAS menu Solutions � Accessories � Registry Editor. When theRegistry Editor opens Products � BASE � EFI � GuessingRows

PUTNAMES=YES|NOspecifies whether the EXPORT procedure is to write SAS variable names to thethe first record of the exported data file.YES specifies that the EXPORT procedure is to:

� Write the SAS variable names to the first row of the exported data file ascolumn headings.

� Write the first row of the SAS data set to the second row of the exporteddata file.

NO specifies that the EXPORT procedure is to write the first row of SAS data setvalues to the first row of the exported data file.

Default: YesNote: If you specify the LABEL= option, the SAS variable labels (not the variable

names) are written as column headings.

Page 38: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

30 Examples of Importing and Exporting Delimited File Types � Chapter 6

Examples of Importing and Exporting Delimited File Types

Example 1. Import a TAB Delimited File into SASThis code illustrates how the IMPORT procedure uses the first row of the tab

delimited file to generate SAS variable names. SAS starts to read data from row 2, andscans 10 rows of data to determine data types for each column. The invoice.txt file savesdata with the tab character (’09’x) as the delimiter.

PROC IMPORT OUT=WORK.TESTFILE="&dlmdir.\invoice.txt"DBMS=TAB REPLACE;

GETNAMES=YES;DATAROW=2;GUESSINGROWS=10;

RUN;

Example 2. Import a Space Delimited File into SAS. The IMPORT procedure generates generic variable names such as VAR1 and VAR2.

It starts to read data from row 2, and scans the default number of rows (20) todetermine the data types for each column.’20’x is the hexadecimal value for a space inASCII code.

PROC IMPORT OUT=WORK.TESTDATAFILE="&dlmdir.\invoice.txt"DBMS=DLM REPLACE;

DELIMITER=’20’x;GETNAMES=NO;DATAROW=2;

RUN;

Example 3. Export a SAS Data Set to a CSV File.The EXPORT procedure exports the SAS data set, SDF.INVOICE, to a CSV file;

invoice.csv. The SAS variable name is not used. The first row of the SAS data set iswritten to the first row of the CSV file.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.INVOICE

OUTFILE="c:\temp\invoice.csv"DBMS=DLM REPLACE;

DELIMITER=’,’;PUTNAMES=NO;

RUN;

Example 4. Import a Subset of a CSV File into SASThe IMPORT procedure starts to read data in rows 6. It reads 10 observations from

the selected columns, in the customer CSV file. The global OBS= option limits thenumber of data rows to import. The OBS=MAX option resets the OBS= option to thedefault value.

OPTIONS OBS=10;PROC IMPORT OUT= WORK.Test (KEEP=Customer_ID Name Address First-Ordered_Date)

Page 39: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Overview of Microsoft Excel Files Essentials 31

DATAFILE= "&dlmdir.\customer.csv"DBMS=CSV REPLACE;

GETNAMES=YES;DATAROW=6;

RUN;OPTIONS OBS=MAX;

Microsoft Excel Workbook Files

Overview of Microsoft Excel Files EssentialsSAS/ACCESS Interface to PC Files Server works with Microsoft Excel workbook 5,

95, 97, 2000, 2002, 2003, 2007. Throughout this document these files are collectivelyreferred to as .xls files, except for version 2007. Microsoft Excel workbook 2007 fileformats are referred to as .xlsb, .xlsm, or .xlsx files. Files that are created with Excel2007 can create and work with all Excel file formats.

An Excel file represents an Excel workbook. An Excel workbook is a collection ofworksheets. A worksheet that was created with a version before Excel 2007 can containup to 256 columns and 65,536 rows in an .xls file.

A cell is the intersection of a column and a row. It is referenced by a column numberand a row number. For example, B5. A cell is the basic unit that saves data in theworksheet. A cell can contain a numeric value or a text value of up to 32,767 characters.

A range is a subset of cells in a worksheet. Its address identifies it: It begins withthe name of the top-left cell and ends with the name of the bottom-right cell, separatedby two periods. For example, the range B2..E8 is the range address for a rectangularblock of 12 cells, where the top-left cell is B2 and the bottom-right cell is E8 (shown asshaded, below). A range name identifies a range.

Excel 2007 has been enhanced to support 16,384 columns and 1,048,576 rows in aworksheet. Files that are created with Excel 2007 can have have an .xlsb, .xlsx, or.xlsm extension. Due to the limitations of the ACE engine and the Jet engine, the SASLIBNAME engine is limited to 255 columns in an Excel file.

Page 40: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

32 Excel Data Types � Chapter 6

Figure 6.1 A Range of Data in an Excel Worksheet

SAS/ACCESS Interface to PC Files Server treats an Excel workbook as a database,and a range (subset of cells in a worksheet) as a table. A range name must be definedin the Excel file before SAS can use it. A worksheet is treated as a special range. Aworksheet name appended with a $ character is treated as a range.

For example, Sheet1 is a sheet name in an Excel file. SAS treats Sheet1$ as a validrange name and uses it to refer to the whole worksheet. You need to use SAS n-literalwhen referring to the sheet name. For example, ’Sheet1$’n. The first row of data in arange is usually treated as a column heading and used to create a SAS variables name.

� Excel 4 files, only one spreadsheet is allowed per file

� Excel 4, Excel 5, and Excel 95 limits are 256 columns, and 16,384 rows

� Excel 97, 2000, 2002, 2003 limits are 256 columns, and 65,536 rows

� Excel 2007 limits are 16,384 columns, and 1,048,576 rows.

� Excel 95 files are treated as the same format as Excel 5 files.

� Excel 2000, 2002, and 2003 files with an .xls file extension are treated as the sameformat as Excel 97 files.

� Excel 2007 has three different file extensions, .xlsb, .xlsm, and .xlsx.

Excel Data TypesMicrosoft Excel software has two data types: character and numeric.

� Character data as labels or formula strings. Character data is generallyconsidered text and can include character type dates and numbers. A cell can saveup to 32,767 characters.

� Numeric data can be entered as numbers or formulas. Numeric data can includenumbers (0 through 9), formulas, or error values (such as #NULL!, #N/A,#VALUE!).

Page 41: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � SAS Import and Export Utilities Support for Excel Files 33

Excel Numeric Data and Time ValuesThe conversion of date and time values between SAS data sets and Microsoft Excel

spreadsheets is transparent to users. However, you are encouraged to understand thedifferences between them.

In Microsoft Excel software, a date value is the integer portion of a number that canrange from 01 January 1900 (saved as integer value: 1) to 31 December 9999 (saved asinteger value: 2,958,465). A Microsoft Excel software time value is the decimal portionof a number that represents time as a proportion of a day. For example, 0.0 is midnight,0.5 is noon, and 0.999988 is 23:59:59 (on a 24-hour clock). While a number can haveboth a date and a time portion, the formats in Microsoft Excel display a number in adate, time, or date/time format.

In SAS software, SAS dates are valid back to AD 1582 and ahead to AD 9,999. Adate value is represented by the number of days between January 01, 1960, and thatdate. A time value is represented by the number of seconds between midnight and thattime of day. A datetime value is represented by the number of seconds betweenmidnight January 01, 1960, and that datetime.

When you export a SAS time value to an Excel file, the value could be displayed as“1/0/1900” in the Excel file. Format the cell with a Time format to see the time valuedisplayed correctly.

Excel File FormatsIf you use ’Save As’ and select ’Save As type’ of ’Excel 97–2003 Workbook’, the file is

saved as an .xls file in that format. Under ’Save As’ you can select the other 2007formats:

� Excel Workbook creates a .xlsx file.

� Excel Macro-Enabled Workbook creates an .xlsm file.

� Excel Binary Workbook creates an .xlsb file.

� Excel 97–2003 Workbook creates an .xls file.

SAS Import and Export Utilities Support for Excel Files

SAS Import and Export Utilities provide three components to access Microsoft Excelfiles.

LIBNAMEstatement

generates a LIBNAME statement and PROC SQL code for the PCfiles engine read data from or write data to an Excel file. Thiscomponent supports Excel versions 5, 95, 97, 2000, 2002, 2003, and2007.

See: “LIBNAME Statement:PC Files on Microsoft Windows” onpage 79

The ACCESSand DBLOADprocedures

generate ACCESS procedure code to read data from an Excel file.Also, generates the DBLOAD procedure code to write data to anExcel file. This component supports only Excel versions 4 and 5/95.This is for SAS 6 compatibility support and is available only onMicrosoft Windows.

See: “Importing and Exporting Microsoft Excel Files with theACCESS and DBLOAD Procedures” on page 42.

Page 42: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

34 LIBNAME Statement Options to Import or Export Excel Data � Chapter 6

.xls file formats translates Excel .xls file formats to read data from or write data toan Excel file. This component supports Excel versions 5/95, 97,2000, 2002, and 2003. For details about available statements.Restriction: This component does not support V 2007 .xlsb or .xlsx

files.Restriction: This component does not currently support such

DBCS character sets as Chinese, Japanese, and Korean.See: “ACCESS Procedure Syntax” on page 198.

LIBNAME Statement Options to Import or Export Excel DataThe LIBNAME statement component for importing and exporting Microsoft Excel

workbook data generates SAS LIBNAME statement code. The LIBNAME statementuses the Microsoft Ace engine or Microsoft Jet engine to access data in Microsoft Excelworkbook files.

Table 6.2 LIBNAME Statement Options to Import or Export Excel Data

Data Source Syntax Valid ValueDefaultValue

PROCIMPORT

PROCEXPORT

DBDSOPTS=Excel data set

optionsYes Yes

DBSASLABEL= Compat|None Compat Yes No

GETNAMES= Yes|No Yes Yes No

MIXED= Yes|No No Yes No

NEWFILE= Yes|No No No Yes

RANGE= range name Yes No

SCANTEXT= Yes|No Yes Yes No

SCANTIME= Yes|No Yes Yes No

SHEET= sheet name Yes Yes

TEXTSIZE= 1 to 32767 1024 Yes No

EXCEL

EXCEL97

EXCEL2000

EXCEL2002

EXCEL2003

EXCEL2007

USEDATE= Yes|No Yes Yes No

SAS LIBNAME statement options to import or export Excel Data files on Linux,Windows and UNIX. This component requires that the PC Files Server is running on aMicrosoft Windows operating platform where the PC files reside.

Page 43: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � IMPORT and EXPORT Procedure Options for Excel Files 35

Table 6.3 SAS LIBNAME Statement Options to Import or Export Excel Data fileson Linux, Windows and UNIX

DataSource

Syntax Valid Value DefaultValue

PROCIMPORT

PROCEXPORT

DBDSOPTS= ’Excel data setoptions’

Yes Yes

DBSASLABEL= Yes|No Yes Yes No

PORT= 1 to 65535 Yes Yes

RANGE= ’range name’ Yes No

SCANTEXT= Yes|No Yes Yes No

SCANTIME= Yes|No Yes Yes No

SERVER= ’server name’ Yes Yes

SERVERPASS= ’server password’ Yes Yes

SERVERUSER= ’server User ID’ Yes Yes

SERVICE= ’service name’ Yes Yes

SHEET= ’sheet name’ Yes Yes

SSPI=

64-bit Windowsonly

Yes| No No Yes Yes

TEXTSIZE= 1 to 32767 1024 Yes No

USEDATE= Yes|No Yes Yes No

EXCELCS

VERSION= ’5’ | ’95’ | ’97’ |’2000’ | ’2002’ |’2003’ | ’2007’

’97’ Yes Yes

IMPORT and EXPORT Procedure Options for Excel FilesDBDSOPTS=any data set options that are valid for the SAS Excel LIBNAME engine

enables data set options for the LIBNAME engine such as READBUFF=,INSERTBUFF=, DBTYPE=, DROP=, FIRSTOBS=, and OBS=. These options arefor advanced users who are familiar with the PC Files LIBNAME engine.

Default: 1for UNIX users who use the client server model with an Excelworkbook.

Note: To improve performance for reading data, set the READBUFF= option to25 or higher.

Enclose the options in single or double quotation marks as shown in theseexamples: DBDSOPTS=’FIRSTOBS=10 READBUFF=25’;.

If the option string that you specify contains single quotations marks, usedouble quotation marks around it in your statement.

For example: DBDSOPTS="DBTYPE=(BilledTo=’CHAR(8)’)";.See “Data Set Options” on page 92 and “Data Set Options for PC Files on Linux

and UNIX, and 64-Bit Windows” on page 162 for a list of supported data setoptions.

DBSASLABEL=COMPAT|NONE|YES|NO

Page 44: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

36 IMPORT and EXPORT Procedure Options for Excel Files � Chapter 6

specifies the data source column names.

COMPAT specifies that the data source column headings are saved as thecorresponding SAS label names.Alias: YES

NONE specifies that the data source column headings are not saved asSAS label names. The SAS label names are then left as blanks.Alias: NO

GETNAMES=YES|NOspecifies whether the IMPORT procedure is to generate SAS variable names fromthe data values in the first row of the import file.

If data in the first row of the input file contains special characters for a SASvariable name, such as a blank; SAS converts the character to an underscore. Forexample, the column heading.

YES specifies that the IMPORT procedure generate SAS variablenames from the data values in the first row of the importedExcel file.

NO specifies that the IMPORT procedure generate SAS variablenames as F1, F2, F3, and so on.

Default: YesRestriction: Valid only for Windows.

Restriction: Valid only for the IMPORT procedure.Restriction: Supported only when DBMS=EXCEL.Restriction: When SAS reads the data value in the first row of the input file,

SAS checks for invalid SAS name characters (such as a blank). Invalidcharacters are converted to an underscore. For example, the data valueOccupancy Code becomes the SAS variable name Occupancy_Code.

MIXED=YES|NOassigns a SAS character type for the column and converts all numeric data valuesto character data values when mixed data types are found.Default: NORestriction: Supported only when DBMS=EXCEL.Restriction: If MIXED=YES, the connection is set to import mode and updates

are not allowed.Note: Due to a limitation in the Microsoft Ace engine and the Microsoft Jet Excel

engine, using MIXED=YES could result in improper text variable lengths.

NO assigns numeric or character type for the column, depending onthe majority of the type data that is found.

Restriction: Numeric data in a character column and characterdata in a numeric column are imported as missing values.

These registry settings can affect the behavior of the MIXED= option. Theoptions are located in theHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\AccessConnectivity Engine\Engines\Excel key of the Microsoft Windows registry. Tochange the value of TypeGuessRows, follow these steps in Microsoft Windows:

1 Start � Run

Enter Regedt32 select OK.2 Open this key in the Registry Editor window:

Page 45: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � IMPORT and EXPORT Procedure Options for Excel Files 37

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\AccessConnectivity Engine\Engines\Excel

3 Double-click TypeGuessRows.

4 Select Decimal, enter 0 in the Value field, and select OK.

5 Exit from the Registry Editor window.

Table 6.4 Registry Settings for the MIXED Option

TypeGuessRows An integer type with a default value of 8. You can use the number ofrows in the worksheet range in scans to determine column types. Ifyou set this type to 0, all rows up to 16384 in the range are checked.

Microsoft states that the valid range of TypeGuessRows is 0–16.However, you could set as high as 16384, and it would still operate

correctly.

CAUTION:Changing the TypeGuessRows value cause a scan to fail ifyou set it higher than 16384. It also affects any softwarethat uses the Microsoft Ace provider to access Excel filedata, including accessing Excel data in a Microsoft Accessdatabase. The TypeGuessRows value is registered with andcontrolled by Microsoft. It is recommended that you set thevalue to 0. �

ImportMixedTypes A string type with a default value of Text. If a column contains morethan one type of data while scanning TypeGuessRows rows, the

column type is determined to be Text if the setting value is Text. Ifthe setting value is Majority Type, the most common column type

determines the column type.

For the MIXED=YES option to work correctly, you should you changeTypeGuessingRows to 0 in the Microsoft Windows registry so that allrows in the specified range are scanned. As a result, when you use

MIXED=YES, the Microsoft Ace engine and the Microsoft Jet enginealways assign character type for columns with data of mixed data

types.

The numeric data is converted to character data.

NEWFILE=YES|NOwhen exporting a SAS data set to an existing Excel file, specifies whether to deletethe specified Excel file, and load the SAS data set to a sheet in a new Excel file.

YES specifies that the EXPORT procedure deletes the specifiedExcel file, if it exists, and loads the SAS data set to a sheet inthe new Excel file.

NO specifies that the EXPORT procedure loads the SAS data set toa sheet and appends it to the existing Excel file. If the specifiedExcel file does not exist, an Excel file is created, and the SASdata set is loaded.

Restriction: Available only when DBMS=EXCEL.

PORT=port-numberspecifies the number of the port that is listening on the PC Files Server. The validvalue is between 1 and 65535. This port or service name displays on the PC FilesServer display when the application is started in server mode.

Page 46: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

38 IMPORT and EXPORT Procedure Options for Excel Files � Chapter 6

Default: 8621Alias: PORT_NUMBERRestriction: Available only for the client server model.Restriction: The PORT= statement option and the SERVICE= statement option

should not be used in the same procedure

RANGE=range-name|absolute-rangesubsets a spreadsheet by identifying the rectangular set of cells to import. Therange name is the user defined spreadsheet name, to represent a range of cellswithin the spreadsheet in the Excel file. The range name is not case sensitive anddoes not allow any special character, except an underscore. You must define rangename with a workbook scope so that the name is visible to SAS.

When data is imported from an Excel file, a sheet name that is appended with a$ character is treated as a range name. The range name refers to the whole sheet.

You can use the DATASETS procedure to list the data set names, that aremapped to the range names. If the displayed range name contains single quotes,keep the single quotes as part of the range name to access the sheet. For example,to retrieve data from the spreadsheet for two separate sheet names, My#Test andCustomerOrders:

RANGE="’My#Test$’";RANGE="’ CustomerOrders$’";

Absolute range identifies the top-left cell that begins the range and thebottom-right cell that ends the range.

Example 1. C2:F12 represents cells within Column C, Row 2, and Column F,Row 12. Here is another example:

RANGE="’summary$a4:b20’";

Example 2, $ indicates the end of the sheet name, colon (:) separates the valuesfor upper left (UL) and lower right (LR) of the cell range. If this statement is notspecified, the IMPORT procedure reads the entire spreadsheet as a range.

If the range name is available, it is recommended that you use RANGE= optionwithout the SHEET= option for the IMPORT procedure. To use the absolute rangeaddress, it is strongly recommended that you use the full range address withquotes. For example, specify ’sheet_name$A1:C7’n. Use the SHEET= option onlywhen you want to access the whole sheet.Restriction: Supported only for the IMPORT procedure.

SCANTEXT=YES|NOspecifies whether to scan the column to determine the length of the text data foreach data source column. This option applies only to character data type columns.

YES scans the length of text data for a data source column and usesthe length of the longest string of data that it finds as the SASvariable width. If the maximum length that it finds is greaterthan the value in the TEXTSIZE= option, the smaller value inTEXTSIZE= option is applied as the SAS variable width.

NO does not scan the length of text data for a data source column.The column length returned from the Microsoft Ace orMicrosoft Jet engine is used as the SAS variable width. If thereturned column width is greater than what is specified in theTEXTSIZE= option, the smaller value specified in TEXTSIZE=option is applied as the SAS variable width.

Specify SCANTEXT=NO when you need to update data in aMicrosoft Excel workbook.

Page 47: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � IMPORT and EXPORT Procedure Options for Excel Files 39

Alias: SCAN_TEXT|SCANMEMONote: So that the SCANTEXT=YES option works correctly, it is strongly

recommended that you change TypeGuessingRows to 0 in the MicrosoftWindows registry. This ensures that all rows in the specified range are scanned.To correct truncated text data for DBCS users (including Chinese, Japanese,

and Korean), you can set the environment variable DBE_DBCS to YES. Thisdoubles the scanned text data length and therefore corrects the problem oftruncated text data. To set the DBE_DBCS environment variable, submit thisstatement: Options set=DBE_DBCS YES;.

The Microsoft Ace or Microsoft Jet engine handles the SCANTEXT= option.These registry settings could affect the behavior of the SCANTEXT= option.

These are located in theHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\AccessConnectivity Engine\Engines\Excel key of the Microsoft Windows registry.

Table 6.5

TypeGuessRows An integer type with a default value of 8. The number of rows in theworksheet range is used to scan to determine column types. If set to0, all rows in the range are checked. Microsoft states that the validrange of TypeGuessRows is 0 to 16. However, it could be set as highas 16384 and still operate correctly.

ImportMixedTypes A string type with a default value of Text. If a column contains morethan one data type when scanning of TypeGuessRows rows, thecolumn type is determined to be Text if the setting value is Text. Ifthe setting value is Majority Type, the most common column typedetermines the column type.

SCANTIME=YES|NOspecifies whether to scan the date/time data while importing data from a date/timecolumn from the Microsoft Excel workbook.

YES scans the date/time column and assigns the TIME. format for adate/time column only if time values are found in the column.

NO specifies not to scan the date/time column.� The DATETIME. format is assigned for a date/time

column if USEDATE=NO.� The DATE. format is assigned for a date/time column if

USEDATE=YES.

SERVER=PC-Files-Server-namespecifies the PC Files Server name. Excel supports spreadsheet names up to 31characters. SAS supports data set names up to 32 characters. You must bring upthe listener on the PC Files Server before you can establish a connection. You canconfigure the service name, port number, maximum number of concurrentconnections allowed, and data encryption on your PC Files Server.Alias: SERVER_NAME.Note: Required statement.Restriction: Available only for client server model.See: Chapter 11, “PC Files Server Administration,” on page 139.

SERVICE=service-name

Page 48: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

40 IMPORT and EXPORT Procedure Options for Excel Files � Chapter 6

specifies the service name that is defined on your service file for your client andserver machines. This port number or service name is displayed on the PC FilesServer control panel screen when it is started on the PC. The service name needsto be defined on your UNIX machine and your PC Files Server.Alias: SERVER_NAMERestriction: SERVICE= and PORT= options should not be used in the same

procedure.Restriction: Available only for client server model.

SHEET=sheet-nameidentifies a particular spreadsheet in an Excel workbook. If the sheet-namecontains a special character such as space in the the EXPORT procedure, SASconverts it to an underscore.

For example, a sheet name “Employee Information” becomes’’Employee_Information”.

To ensure that the IMPORT procedure reads the data that you want, identifythe spreadsheet by specifying the RANGE= option or the SHEET= option. If thesheet name contains special characters, you can use the RANGE= instead of theSHEET= option to import data.

If you do not specify this statement, the EXPORT procedure writes thespreadsheet name as the SAS data set name.

If your sheet name contains special characters, use PROC DATASETS to list theavailable data set names. If the sheet name shown contains single quotes, keepthe single quotes as part of the sheet name in order to be able to access the sheet.

For example, specify SHEET="’My#Test’";

Note: it is recommended that you use the RANGE= option without the SHEEToption in the IMPORT procedure. Use the SHEET= option only when you wantto import the entire spreadsheet.

Note: If both the range name and the sheet name are missing, the IMPORTprocedure reads the first spreadsheet in the workbook. If you do not specify thisstatement, the IMPORT procedure reads the first spreadsheet that wasphysically saved in the Excel file.

Restriction: use the SHEET option only when you want to import the entirespreadsheet.

Restriction: Avoid sheet-names that look like cell references, which have <1–3characters> plus 1 or more digits. For example, A1, IV65536, TRY123,XFD1048576.

SSPI=YES|NOenables the server administrator to allow Integrated Windows Authentication.This is a mechanism for the Windows client and server to exchange credentials.Default: NoNote: SSPI can also be enabled by specifying the –SSPI option on the SAS

command line.Restriction: Valid only when used on a 64–bit Windows PC.

TEXTSIZE=1 to 32767specifies the SAS maximum variable length that is allowed while importing datafrom Microsoft Excel text columns. Any text data in Excel whose length exceedsthis value is truncated when it is imported into SAS.Alias: DBMAX_TEXT

USEDATE=YES|NOspecifies whether to assign a DATE or a DATETIME format while importing adate/time column from a Microsoft Excel workbook.

Page 49: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � IMPORT and EXPORT Procedure Options for Excel Files 41

YES assigns the DATE format for the corresponding date/timecolumn in the Microsoft Excel table.

NO assigns the DATETIME format for the corresponding date/timecolumn in the Microsoft Excel table.

See: The SCANTIME= statement, to assign the appropriate TIME formatSee also: “Processing Date and Time Values between SAS and Microsoft Excel”

on page 131.

VERSION=file-version’specifies the version of the file that you want to create.Default: the default value is 97 for .xls filesNote: Always enclose the version in single quotes.Restriction: If the file exists on the PC Files Server, this statement is ignored.Restriction: Available only for client server model.Valid Values: 2007, 2003, 2002, 2000, 97, 95, and 5

Example 1: Export a SAS Data Set to an Excel FileThis example exports a SAS data set called SDF.ORDERS to an Excel 2007 .xlsb file

with the Orders sheet name. In this case, SHEET supports only an .xlsb file.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.ORDERS

FILE="c:\temp\demo.xlsb"DBMS=EXCEL REPLACE;

SHEET="Orders";RUN;

Example 2: Import a Range from Excel 2007 File to a SAS Data SetThis example imports a range named INVOICE from an Excel workbook file and

performs these tasks:� uses the first row of data as column names� scans length for character type columns� assigns DATETIME. format for date/time columns� leaves SAS labels blank� limits the size of text fields to be less than or equal to 512 characters

PROC IMPORT OUT=WORK.INVOICEFILE="&demodir.demo.xlsb"DBMS=EXCEL REPLACE;

RANGE="INVOICE";GETNAMES=YES;SCANTEXT=YES;USEDATE=NO;SCANTIME=YES;DBSASLABEL=NONE;TEXTSIZE=512; /* default is 1024 */

RUN;

Example 3: Import a Range From an Excel File on a PC Files Server to aSAS Data Set

The code in this example imports a range named Orders from an Excel file on a PCFiles Server. It assigns the DATETIME. format for date/time columns.

Page 50: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

42 Importing and Exporting Microsoft Excel Files with the ACCESS and DBLOAD Procedures � Chapter 6

PROC IMPORT OUT=WORK.ORDERSDATAFILE="&pcfdir.demo.xls"DBMS=EXCELCS REPLACE;

RANGE="Orders";SERVER="&server";PORT=8621;USEDATE=NO;SCANTIME=YES;

RUN;

Example 4: Export a SAS Data Set to an Excel Workbook FileThis code exports a SAS data set named SDF.CUSTOMER to an Excel workbook file,

with Customer sheet name on the PC Files Server.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="c:\temp\demo.xls"DBMS=EXCELCS REPLACE;

SHEET="Customer";SERVER="&server";SERVICE=SASPCFILE;

RUN;

Example 5: The IMPORT Procedure Using SSPI - Microsoft 64–bit Windowsproc import out=work.test datafile=’C:\myFile.xlsb’ dbms=excelcs replace;

server=filesrv;port=8621;sspi=yes;

run;

Importing and Exporting Microsoft Excel Files with the ACCESS andDBLOAD Procedures

The IMPORT and EXPORT components use the ACCESS and DBLOAD proceduresbehind the scenes to access data in Microsoft Excel files. Excel 2007, .xlsx, .xlsb, or.xlsm files are not supported. The ACCESS and DBLOAD procedures are available onlyon Microsoft Windows.

Note: Because the ACCESS and DBLOAD procedures are compatible only with SAS6 procedures, they ignore SAS system options such as the VALIDVARNAME = option.The ACCESS procedure and the DBLOAD procedure have other SAS 6 limitations suchas a maximum of 8-byte SAS variable names and a maximum of 200-character value. �

The following table lists the statements that are available to import data from orexport data to an Excel file using the ACCESS and DBLOAD procedures. For examplesof these statements, see “ACCESS and DBLOAD Procedures Options” on page 43.

Page 51: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � ACCESS and DBLOAD Procedures Options 43

Table 6.6 Available Statements for Importing and Exporting Excel Files Using theACCESS and the DBLOAD Procedures

DataSource

Syntax Valid Value DefaultValue

PROCIMPORT

PROCEXPORT

GETNAMES= Yes|No Yes Yes No

RANGE= Range Name or AbsoluteRange Value, such as

’A1..C4’

Yes No

EXCEL5

SHEET= Sheet name Yes No

GETNAMES= Yes| No Yes Yes NoEXCEL4

RANGE= Range Name or AbsoluteRange Value, such as

’A1..C4’

Yes No

ACCESS and DBLOAD Procedures OptionsGETNAMES=YES|NO

specifies whether the IMPORT procedure is to generate SAS variable names fromthe data values in the first row of the import file.

If data in the first row of the input file contains special characters for a SASvariable name, such as a blank; SAS converts the character to an underscore. Forexample, the column heading.

YES specifies that the IMPORT procedure generate SAS variablenames from the data values in the first row of the importedExcel file.

NO specifies that the IMPORT procedure generate SAS variablenames as F1, F2, F3, and so on.

Default: Yes

Restriction: Valid only for Windows.

Restriction: Valid only for the IMPORT procedure.

Restriction: Valid only when DBMS=EXCEL.

Restriction: When SAS reads the data value in the first row of the input file,SAS checks for invalid SAS name characters (such as a blank). Invalidcharacters are converted to an underscore. For example, the data valueOccupancy Code becomes the SAS variable name Occupancy_Code.

Example 1: Export SAS Data Sets to Excel Workbook Files

This code exports the SDF.INVOICE and SDF.ORDERS SAS data sets to Excelworkbook files with Invoice and Orders as sheet names.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.INVOICE

FILE="&tmpdir.text.xls"DBMS=XLS REPLACE;

SHEET="Invoice";RUN;

Page 52: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

44 Microsoft Access Database Files � Chapter 6

PROC EXPORT DATA=SDF.ORDERSFILE="&tmpdir.text.xls"DBMS=XLS REPLACE;

SHEET="Orders";RUN;

Example 2: Import Data Using a Range NameThis code imports SAS data from an .xls file using a range name.

PROC IMPORT OUT=WORK.INVOICEFILE="&demodir.demo.xls"DBMS=XLS REPLACE;

RANGE="INVOICE";GETNAMES=YES;

RUN;

Example 3: Import Data Using an Absolute Range AddressImport SAS data from an .xls file using an absolute range address.

PROC IMPORT OUT=WORK.INVOICEFILE="&demodir.demo.xls"DBMS=XLS REPLACE;

RANGE="Invoice$B4:D10";GETNAMES=NO;

RUN;

Microsoft Access Database Files

Microsoft Access File EssentialsSAS/ACCESS Interface to PC Files Server works with Microsoft Access database 97,

2000, 2002, 2003, and 2007 files.Microsoft Access is a desktop relational database system that uses the Microsoft Ace

engine or the Microsoft Jet engine to store and retrieve data.A database is a collection of information that is related to a particular subject or

purpose, such as tracking customer orders or maintaining a music collection. All objectsin an MS Access database ( tables, queries, forms, reports) are stored in the Jet .mdb orAce .accdb format, if the size is greater than, or equal to MS Access database 2007.

The following table lists the maximum size limits for the components of .mdb and.accdb files.

Table 6.7 Microsoft Access Database (.mdb and .accdb) Maximum Size Limits PerComponent

File size 2GB / 32,768 objects

Number of fields per table 255

Number of characters per text field 255

Page 53: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Microsoft Access Data Types 45

Memo field size 65535 characters

Table name size 64 characters

Field name size 64 characters

Record size 2000 characters (excluding memo and OLEobject fields) for .mdb

4000 characters (excluding memo and OLEobject fields) for .accdb

While importing data from a table, SAS converts special characters in a table nameto underscores ( _ ) in the corresponding data set name. If a field contains specialcharacters, SAS converts special to underscores in the corresponding variable name.

Microsoft Access Data TypesSummary of field data types that are available in Microsoft Access; their uses; and

their storage sizes.

ATTACHMENTS use to attach images, spreadsheet files, documents, charts, and othertypes of supported files to rows in your database.Note: New for Microsoft Access 2007

AUTONUMBER use for unique sequential (incrementing by 1) or random numbersthat are automatically inserted when a row is added. Stores 4 bytes;stores 16 bytes for Replication ID (GUID).

CURRENCY use for currency values and to prevent rounding during calculations.Stores as 8–byte numbers with precision to four decimal places.

DATE/TIME use for dates and times. Stores as 8–byte numbers.

HYPERLINK use for hyperlinks. A hyperlink can be a UNC path (link) or a URL(link). Stores up to 64,000 characters.

MEMO use for lengthy text and numbers, such as notes or descriptions.Stores up to 32767 characters.

NUMBER use for data to be included in mathematical calculations, except forcalculations involving money (use Currency type). Stores 1, 2, 4, or 8bytes; stores 16 bytes for Replication ID (GUID). The FieldSizeproperty defines the specific Number type.

OLE OBJECT use for OLE objects (such as Microsoft Word documents, MicrosoftExcel spreadsheets, pictures, sounds, or other binary data) createdin other programs using the OLE protocol (link). Stores up to 1gigabyte (limited by disk space).

TEXT use for text or combinations of text and numbers, such as addresses,numbers that do not require calculations, telephone numbers, partnumbers, or postal codes. Stores up to 255 characters. The FieldSizeproperty controls the maximum number of characters that can beentered.

YES|NO use for data that can be only one of two possible values, such asYes|No, True|False, On|Off. Stores 1 bit. Use -1 for Yes value and0 for No value.

Restriction: Null values are not allowed.

Page 54: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

46 The Conversion of Date and Time Values between SAS Data Sets and Microsoft Access Database � Chapter 6

The Conversion of Date and Time Values between SAS Data Sets andMicrosoft Access Database

In Microsoft Access database software:

� Date values are valid back to 30 December 1899 and is saved as integer value: 0.

� Date values are valid ahead to 31 December 9999, and is saved as the integer:2,958,465.

� Considers years 4000 and 8000 as leap years.

� Time value is the decimal portion of a number that represents time as aproportion of a day.

� Numbers can have both a date and a time portion, the format is in date/timeformat.

� Displays a number in a date, time, or data/time format.

In SAS:

� Dates are valid back to A.D.1582.

� Date values before year 1582 is represented as a missing value.

� Dates are valid ahead to A.D. 9,999.

� Date values are represented by the number of days between January 01, 1960, andthat date.

� Years 4000 and 8000 are not considered leap years.

� Time values are represented by the number of seconds between midnight and thattime of day.

� Datetime values are represented by the number of seconds between midnightJanuary 01, 1960, and that datetime.

� Time values can be imported as a date value 30 Dec 1899, ensure that you assignthe correct format.

The IMPORT and EXPORT Procedure Statements for Access FilesBefore you use the IMPORT and the EXPORT procedures for Access files, it is

helpful to be familiar with Access file formats. For an existing .mdb, you can specifyDBMS=ACCESS on Windows platforms and SAS identifies the version.

� Access 2000, 2002, and 2003 share the same .mdb file formats. ACCESS2000,ACCESS2002, and ACCESS2003 are treated as aliases for Access in SAS.

� Access 2007 supports .accdb file formats

� Access 97 has different formats, which are incompatible with Access 200x versions.Specify DBMS=ACCESS97 on Windows platforms only, to export and create a new.mdb file with Access version 97 formats.

These tables list the statements that are available to import data from an Accessdatabase file, using the LIBNAME statement on a Windows operating system platform.See “Example 1: Import a SAS Data Set from an Access 2007 Database Table” on page52.

Page 55: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � The IMPORT and EXPORT Procedure Statements for Access Files 47

Table 6.8 IMPORT and EXPORT Procedure Statements for Access Files onWindows

DataSource

Syntax Valid Value DefaultValue

PROCIMPORT

PROCEXPORT?

DATABASE= Complete path andfilename for theMicrosoft

Access database file

Yes Yes

DBDSOPTS= Any valid data setoptions for Microsoft

Access database engine

Yes Yes

DBPASSWORD= database password Yes Yes

DBSASLABEL= Yes|No Yes Yes No

MEMOSIZE= 1 to 32767 1024 Yes No

PASSWORD= user password Yes Yes

SCANMEMO= Yes|No Yes Yes No

SCANTIME= Yes|No Yes Yes No

USEDATE= Yes|No No Yes No

USER= User ID Yes Yes

ACCESS

ACCESS97

ACCESS2000

ACCESS2002

ACCESS2003

ACCESS2007

DBSYSFILE= complete path andfilename for the

WorkgroupAdministration file

Yes Yes

On Linux, UNIX, and Windows 64-Bit operating platforms, you can use the clientserver model to access data in .mdb files and .accdb files. For more information, seeChapter 11, “PC Files Server Administration,” on page 139.

For an existing .mdb, you can specify DBMS=ACCESSCS when using the clientserver model and SAS identifies the version of Access for you. You can specifyVERSION=’97’ when using the client server model only when you want to export andcreate a new .mdb file with Access version 97 formats.

Note: If the client server model is used, the SAS client cannot access an Accessdatabase file with both database password protection and user level security protection.In this case, you must choose only one security protection to be able to access yourAccess database file from a SAS client. �

The following table lists the statements to import data from an Access database fileusing the client server model. The statements are valid on Linux, UNIX, and Windows64-bit operating platforms.

Page 56: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

48 The IMPORT and EXPORT Procedure Statements for Access Files � Chapter 6

Table 6.9 IMPORT and EXPORT Procedure Statements for Access Files on Linux,UNIX, and Windows 64-Bit Operating Platforms

DataSource

Syntax Valid ValueDefaultValue

PROCIMPORT

PROCEXPORT

DATABASE=

“complete path andfilename for theMicrosoft Access

database file”

Yes Yes

DBDSOPTS=’any valid data set

options for MicrosoftAccess database engine’

Yes Yes

DBPASSWORD= ’database password’ Yes Yes

DBSASLABEL= Yes|No Yes Yes No

MEMOSIZE= 1 to 32767 1024 Yes No

PASSWORD= ’user password’ Yes Yes

PORT= 1 to 65535 8621 Yes Yes

SCANMEMO= Yes|No Yes Yes No

SCANTIME= Yes|No Yes Yes No

SERVER= ’server name’ Yes Yes

SERVERPASS= ’server password’ Yes Yes

SERVERUSER= ’server User ID’ Yes Yes

SERVICE= ’service name’ Yes Yes

SSPI= Yes|No Yes Yes

USEDATE= Yes|No No Yes No

USER= ’User ID’ Yes Yes

VERSION=’97’ |’’2000’ | ’2002’ |

’2003’ | ’2007’’2000’ Yes Yes

ACCESSCS

DBWSYSFILE=

’complete path andfilename for the

WorkgroupAdministration file’

Yes Yes

DATABASE=databasespecifies the complete path and filename of the Access database file that containsthe specified DBMS table. If the database name does not contain lowercasecharacters, special characters, or national characters ($, #, or @), you can omit thequotation marks.Note: SAS does not generate a default value, but you can configure one in the

DBMS client software

DBDSOPTSdata set options that are valid for the Access database LIBNAME engine

Enables you to take advantage of useful data set options for the LIBNAMEengine such as READBUFF= , INSERTBUFF= , DBTYPE= , DROP= ,FIRSTOBS= , and OBS=. This option is for advanced users who are familiar withthe PC files LIBNAME engine.

Page 57: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � The IMPORT and EXPORT Procedure Statements for Access Files 49

Note: For users who use the client server model to access data in an Accessdatabase, the default value for READBUFF= is 1. To improve performance forreading data, set READBUFF= to 25 or higher.

Note: For users who use the client server model to access data in an Accessdatabase, the default value for INSERTBUFF= is 1. To improve performance forwriting data, set INSERTBUFF= to 25 or higher.

See: For a list of supported data set options, please refer to “Data Set Options”on page 92 or “Data Set Options for PC Files on Linux and UNIX, and 64-BitWindows” on page 162.

Restriction: You must surround the options in single quotation marks.Example:

DBDSOPTS=’FIRSTOBS=10 READBUFF=25’;

Restriction: If the option string that you are specifying contains single quotationsmarks, you must use double quotation marks around it in your statement.

Example:

DBDSOPTS="DBTYPE=(BilledTo=’CHAR(8)’)";

DBPASSWORD=database-file-passwordenables you to access a file if database-level security is set in the .mdb file. Adatabase password is case sensitive. You can define a database password insteadof user-level security.Alias: DBPWD|DBPW

DBSASLABEL=COMPAT|NONEspecifies whether the data source column names are saved as the correspondingSAS label names.

MEMOSIZE=1 to 32767Specifies the maximum variable length in SAS that is allowed while importingdata from memo columns of an Access database table. Any memo data in anAccess database tables whose length exceeds 32767 is truncated when it isimported into SAS.Alias: DBMAX_TEXTRestriction: If the maximum length that SCANMEMO= option is greater than

the value of the MEMOSIZE= option, the smaller value in the MEMOSIZE=option is applied as the SAS variable width.

PORT= PORT NUMBERspecifies the number of the port that is listening on the PC Files Server. The validvalue is between 1 and 65535. This port or service name displays on the PC FilesServer display when the application is started in server mode.Default: 8621Alias: PORT_NUMBERRestriction: Available only for the client server model.Restriction: The PORT= statement option and the SERVICE= statement option

should not be used in the same procedure

SCANMEMO=YES|NOspecifies whether to scan the memo data to determine the column length for eachmemo type source column.

YESscans the length of memo data for a data source column. Uses the length ofthe longest memo text of data that it finds, as the SAS variable width.

Page 58: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

50 The IMPORT and EXPORT Procedure Statements for Access Files � Chapter 6

Restriction: if the maximum length that SCANMEMO= option is greaterthan the value of the MEMOSIZE= option, the smaller value in theMEMOSIZE= option is applied as the SAS variable width.

NOdoes not scan the length of memo data for a data source column. The columnlength returned from the Microsoft Ace engine or the Microsoft Jet engine isused as the SAS variable length.

Restriction: SCANMEMO= does not apply to text type columns.Restriction: This option applies only to memo data type columns.

SCANTIME=YES|NOspecifies whether to scan the date/time data while importing data from a date/timecolumn from an Access database.

YESscans the date/time column and assigns the TIME. format for a date/timecolumn only if time values are found in the column.Note: The DATE. format is assigned for a date/time column if

USEDATE=YES.

NOspecifies not to scan the date/time column.Note: The DATETIME. format is assigned for a date/time column if

USEDATE=NO.

SERVER=PC server-namespecifies the name of the PC Files Server. You must bring up the listener on thePC Files Server before you can establish a connection to it. You can also configure:

� the service name� the port number� the maximum number of concurrent connections� encrypt the data

Alias: SERVER_NAMENote: This statement is a required.Restriction: Available only for the client server model.

SERVERPASS=server-user-passwordspecifies the password for the User ID given. If the account has no password, omitthis option. Always enclose the value in quotes, to preserve the case of thepassword.Alias: SERVERPASSWORD | SERVERPW | SERVERPWDNote: Passwords are generally case-sensitive.Note: Use the PASSWORD= option for database passwords.Example: LIBNAME using explicit user name and password, for PC Files Server:

LIBNAME db pcfiles path=’C:\myfile.mdb’server=fileserv;serveruser=’mydomain\myusername’;serverpass=’mypassword’;

SERVERUSER=server-user-namespecifies a domain and User ID that is valid for the PC running PC Files Server.Always enclose the value in quotes, otherwise the backslash can be misinterpretedby the SAS parser.

Page 59: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � The IMPORT and EXPORT Procedure Statements for Access Files 51

Alias: SERVERUIDNote: If you are not on a domain, omit the domain name and the backslash.Note: Use the USER= option for database User IDs.Example: LIBNAME using explicit user name and password, for PC Files Server.

LIBNAME db pcfiles path=’C:\myfile.mdb’server=fileserv;serveruser=’mydomain\myusername’;serverpass=’mypassword’;

SERVICE= service-namespecifies the service name that is defined on your service file for your client andserver machines. This port number or service name is displayed on the PC FilesServer control panel screen when it is started on the PC in server mode.Alias: SERVICE_NAMENote: This service name needs to be defined on both your UNIX machine and

your PC Files Server.Restriction: Available only for client server model.Restriction: This statement and the PORT= statement option should not be used

in the same procedure.

SSPI=YES|NOenables PC Files Server to allow Integrated Windows Authentication. This is amechanism for Windows client and server to exchange credentials.Default: NONote: SSPI can also be enabled by specifying the –SSPI option on the SAS

command line.Restriction: Valid on Windows 64-Bit only.Example: LIBNAME using SSPI.

LIBNAME db pcfiles path=’C:\myfile.mdb’server=localhost;sspi=’yes’;

run;

USEDATE=YES|NOspecifies whether to assign a DATE. or a DATETIME. format while importing adate/time column from a Microsoft ACCESS workbook.

YESassigns the DATE. format for the corresponding date/time column in theMicrosoft ACCESS table.

NOassigns the DATETIME. format for the corresponding date/time column inthe Microsoft ACCESS table.

See also: The SCANTIME= statement option in order to assign the appropriateTIME format.For processing of date/time values between SAS and Microsoft Access, see

“Processing Date and Time Values between SAS and Microsoft Access” on page 136.

VERSION=file-versionspecifies the version of the file that you want to create. Valid values are 2007,2003, 2002, 2000, and 97. The default value depends on the extension of the file.Always surround the version value with single quotation marks.

Page 60: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

52 The IMPORT and EXPORT Procedure Statements for Access Files � Chapter 6

Restriction: Available only for client server model.

Restriction: If the file exists on the PC Files Server, the statement is ignored.

Example 1: Import a SAS Data Set from an Access 2007 Database TableThis code imports a data set named CUSTOMER from the Customers table in a

Microsoft Access database: demo.accdb. The Microsoft Access table was saved inversion 2007 format.

PROC IMPORT OUT=WORK.CUSTOMERDATATABLE="Customers"DBMS=ACCESS REPLACE;

DATABASE="&demodir.demo.accdb";USEDATE=YES;SCANTIME=NO;DBSASLABEL=NONE;

RUN;

Example 2: Export a SAS Data Set and Create an Access Database FileThis code exports a SAS data set named EMPLOYEE and creates a new Microsoft

Access database file named test97.mdb. Note that test97.mdb does exist before theEXPORT procedure is submitted. SAS loads and names the table Employees. It thencreates and saves it in the new file, test97.mdb, in version 97 format.

X "DEL c:\temp\test97.mdb";PROC EXPORT DATA=SDF.EMPLOYEE

OUTTABLE="Employees"DBMS=ACCESS97 REPLACE;

DATABASE="c:\temp\test97.mdb";RUN;

Example 3: Import a Data Set from an Access Database File Using a ReadBuffer

This code imports a data set named INVOICE from the Invoice table in a MicrosoftAccess database named demo.mdb. The read buffer is set to 10 rows.

PROC IMPORT OUT=SDF.INVOICETABLE="Invoice"DBMS=ACCESSCS REPLACE;

DATABASE="&pcfdir.demo.mdb";SERVER=&server;PORT=&port;DBDSOPTS="READBUFF=10";

RUN;

Example 4: Export a SAS Data Set to an Access Database File on a PCFiles Server

This code exports a SAS data set named ORDERS to a new Microsoft Accessdatabase file named TEST.MDB, located on the PC Files Server.

The code performs these tasks:

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.ORDERS (DROP=SPECINST)

Page 61: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � WK n Files Essentials 53

OUTTABLE="Orders"DBMS=ACCESSCS REPLACE LABEL;

SERVER=&server;PORT=&port;VERSION=’97’;DBDSOPTS="INSERTBUFF=20";

RUN;

Lotus 1-2-3 WK n Files

WK n Files EssentialsThis section introduces Lotus 1-2-3 WKn files. It focuses on the terms and concepts

that help you use SAS/ACCESS Interface to PC Files Server.SAS/ACCESS Interface to PC Files Server works with WK1, WK3, and WK4

(releases 4 and 5) files. These files contain data in the form of Lotus 1-2-3 spreadsheets.They are referred to collectively in this document as WKn files, where n representsreleases 1, 3, or 4. SAS/ACCESS Interface to PC Files Server does not support the .123format for files from Lotus SmartSuite 97 software.

Various software products, such as the Lotus 1-2-3 spreadsheet and database system,enable you to use spreadsheet or database files to enter, organize, and performcalculations on data. Spreadsheets are most often used for general ledgers, incomestatements, and other types of financial record keeping. Database files also enable youto organize related information, such as the data in an accounts-receivable journal.

In both spreadsheets and database files, the data is organized according to certainrelationships among data items. These relationships are expressed in a tabular form, incolumns and rows. Each column represents one category of data, and each row can holdone data value for each column.

A Lotus 1-2-3 worksheet is an electronic spreadsheet consisting of a grid of 256columns and 8,192 rows. The intersection of a column and a row is called a cell. Thisdisplay illustrates a portion of a standard 1-2-3 worksheet.

Page 62: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

54 WKn Data Types � Chapter 6

Display 6.1 Columns and Rows of Data in a WKn File

Column letters for each column appear above the worksheet. Columns are lettered Athrough IV (A to Z, AA to AZ, BA to BZ, and so on, to IV). Row numbers for each rowappear to the left of the worksheet. Rows are numbered 1 to 8,192. For WK1 files, onlyone worksheet (worksheet A) is allowed per file. For WK3 and WK4 files, up to 256worksheets (worksheets A-IV) are allowed. However, the SAS/ACCESS interface toWKn files uses only one worksheet and defaults to worksheet A.

A range is a subset of cells in a worksheet. A range is identified by its address, whichbegins with the name of the top-left cell and ends with the name of the bottom-right cellseparated by two periods. For example, the range B2..E8 is the range address for arectangular block of 28 cells whose top-left cell is B2 and whose bottom-right cell is E8(as shaded in the figure).

You can give a name to a range and use the name in commands and formulas insteadof the range address in Lotus 1-2-3. A range name can be up to 15 characters long andshould contain no spaces. For example, if the range B3..D6 is named GRADE_TABLE,the formula @AVG(GRADE_TABLE) has the same value as @AVG(B3..D6).

For more information about ranges and their naming conventions, see the Lotus1-2-3 software documentation.

WKn Data TypesLotus 1-2-3 software has two data types: character and numeric. Lotus 1-2-3

character data can be entered as labels or formula string. Lotus 1-2-3 numeric data canbe entered as numbers or formulas.

Character data is generally considered text and can include dates and numbers ifprefixes are used to indicate character data and to align the data in the cell. Forexample, in Lotus 1-2-3, the value "110 Maple Street uses the double quotation markprefix and aligns the label on the right side of the cell.

Numeric data can include numbers (0 through 9), formulas, and cell entries thatbegin with one of these symbols: +, $, @, -, or #.

Numeric data can also include date and time values. In Lotus 1-2-3 software, a datevalue is the integer portion of a number that can range from 01 January 1900 to 31

Page 63: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Supported Import and Export Components and Statements for WK n Files 55

December 2099, that is, 1 to 73,050. A Lotus 1-2-3 software time value is the decimalportion of a number that represents time as a proportion of a day. For example, 0.0 ismidnight, 0.5 is noon, and 0.999988 is 23:59:59 (on a 24-hour clock).

While a number can have both a date and a time portion, the formats in Lotus 1-2-3display a number only in a date format or a time format. The conversion of date andtime values between SAS data sets and Lotus 1-2-3 spreadsheets is transparent tousers. However, you are encouraged to understand the differences between them.

Supported Import and Export Components and Statements for WK nFiles

The IMPORT|EXPORT component for WKn files uses ACCESS and DBLOADprocedures behind the scenes to access data in WKn files. This component is availableonly in Microsoft Windows.

Because the ACCESS and DBLOAD procedures are compatible only with SAS 6procedures, SAS system options such as the VALIDVARNAME= option are ignored.This component has other SAS 6 limitations such as:

� not being case sensitive� a maximum length of 8 bytes of SAS variable name� maximum length of 200 characters of data values

The following table lists the statements that are available to import and export datafrom Lotus 1-2-3 files using the IMPORT and EXPORT procedures on MicrosoftWindows.

Table 6.10 Import or Export Data from Lotus 1–2–3 files

DataSource

Syntax Valid Value DefaultValue

PROCIMPORT

In ROCEXPORT

GETNAMES= Yes|No Yes Yes No

RANGE= Range Name orAbsolute Range Value

Yes No

WK4

WK3

SHEET= Sheet name Yes Yes

GETNAMES= Yes|No Yes Yes NoWK1

RANGE= Range Name orAbsolute Range Value

Yes No

GETNAMES=YES|NOspecifies whether the IMPORT procedure is to generate SAS variable names fromthe data values in the first row of the import file.

If data in the first row of the input file contains special characters for a SASvariable name, such as a blank; SAS converts the character to an underscore. Forexample, the column heading.

YES specifies that the IMPORT procedure generate SAS variablenames from the data values in the first row of the importedExcel file.

NO specifies that the IMPORT procedure generate SAS variablenames as F1, F2, F3, and so on.

Default: Yes

Page 64: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

56 Supported Import and Export Components and Statements for WK n Files � Chapter 6

Restriction: Valid only for Windows.Restriction: Valid only for the IMPORT procedure.Restriction: Supported only when DBMS=EXCEL.Restriction: When SAS reads the data value in the first row of the input file,

SAS checks for invalid SAS name characters (such as a blank). Invalidcharacters are converted to an underscore. For example, the data valueOccupancy Code becomes the SAS variable name Occupancy_Code.

RANGE=range-name|absolute-rangesubsets a spreadsheet by identifying the rectangular set of cells to import from thespecified spreadsheet. The range names can be up to 15 characters long and arenot case sensitive. If you specify a range name, the name must have beenpreviously defined in the WKn file.

Absolute range identifies the top-left cell that begins the range and thebottom-right cell that ends the range. For example, ’C2..F12’ represents cellswithin Column C, Row 2, and Column F, Row 12.

If this statement is not specified, the IMPORT procedure reads the entirespreadsheet as a range.Restriction: Valid only for the IMPORT procedure.

SHEET= worksheet-letter | <’>worksheet-name<’>; (valid for only the IMPORTprocedure)

identifies a particular spreadsheet in a WKn file. Sheet names can be up to 15characters long and are not case sensitive. A worksheet letter is a one- ortwo-letter alpha character. For WK1 files, there is only one worksheet letter:worksheet A. For WK3 and WK4 files, there can be up to 256 different worksheetletters: worksheet A through worksheet Z and worksheet AA through worksheetIV. The default value is A. For example, specifying WORKSHEET=B identifiesworksheet B from a group of worksheets.

If this statement is not specified, the IMPORT procedure reads the firstspreadsheet physically saved in the WKn file. To be certain that IMPORTprocedure reads the desired spreadsheet, you should identify the spreadsheet byspecifying SHEET= option.

Example 1: Export a SAS Data Set to a WK4 File

This example exports data from SAS data set SDF.EMPLOYEE to a WK4 fileEmployee.wk4 without variables FRSTNAME and MIDNAME.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.EMPLOYEE(DROP=FRSTNAME MIDNAME)

OUTFILE= "&tmpdir.Employee.wk4"DBMS=WK4 REPLACE;

RUN;

Example 2: Import Data from a SAS Data Set from a WK4 FileThis example imports data from a WK4 file named invoice.wk4 into SAS data set

named Invoice. It retrieves data from Sheet A, within range from left top cell, A1, toright bottom cell, D12. It then reads the first row of data in the range as SAS variablenames.

PROC IMPORT OUT=WORK.InvoiceDATAFILE="&wkndir.Invoice.wk4"DBMS=WK4 REPLACE;

Page 65: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � DBF Files Essentials 57

SHEET="A";RANGE="A1..D12";GETNAMES=YES;

RUN;

Example 3: Export Data to a WK1 File from a SAS Data SetThe next example exports data to a WK1 file named Orders.wk1 from a SAS data set

named SDF.ORDERS, without the variable SPECINST.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.ORDERS(DROP=SPECINST)

OUTFILE="&tmpdir.Orders.wk1"DBMS=WK1 REPLACE;

RUN;

Example 4: Import Data from a WK1 File into a SAS Data SetThis example imports data from a WK1 file named Orders.wk1 into a SAS data set

named Test. It retrieves data from left top cell, B5, to right bottom cell, D12. SASassigns name for each variable as VAR0, VAR1, and VAR2.

PROC IMPORT OUT=WORK.TestDATAFILE="&wkndir.orders.wk1"DBMS=WK1 REPLACE;

RANGE="B5..D12";GETNAMES=NO;

RUN;

dBase DBF Files

DBF Files EssentialsThis section introduces dBase DBF files. It focuses on the terms and concepts that

help you use SAS/ACCESS Interface to PC Files Server.DBF files are in a file format that dBASE creates. dBASE is a relational database

management system for PC systems. DBF files can be created using a variety of PCsoftware programs, such as Microsoft Visual FoxPro.

A DBF file contains data that is organized in a tabular format of database fields andrecords. Each database field can contain one type of data, and each record can hold onedata value for each field. This picture illustrates four database fields fromCustomer.DBF and highlights a database field and a record.

Page 66: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

58 DBF Data Types � Chapter 6

database field

CUSTOMER CITY STATE COUNTRY

14324742 San Jose CA USA14569877 Memphis TN USA record14898029 Rockville MD USA26422096 La Rochelle France38763919 Buenos Aires Argentina46783280 Singapore Singapore

DBF Data Types

Every field in a DBF file has a name and a data type. The data type tells how muchphysical storage to set aside for the database field and the form in which the data isstored. This list describes each data type.

CHARACTER(N)

specifies a field for character string data. The maximum length of Nis 254 characters. Characters can be letters, digits, spaces, or specialcharacters.Alias: CHAR

NUMERIC(N,n)

specifies a decimal number. The N value is the total number of digitsthat are used to express the value (precision). The n value is thenumber of digits following the decimal point (scale). The maximumvalues allowed depend on the software product you are using.

dBASE Version N, n

dBASE II 16, 14

dBASE III 19, 15

dBASE III PLUS 19, 15

dBASE IV 20, 18

dBASE 5.0 20, 18

Numeric field types always preserve the precision of their originalnumbers. However, SAS stores all numbers internally asdouble-precision, floating-point numbers so their precision is limitedto 16 digits.Note: If every available digit in a DBF file field is filled with a 9 ,

SAS interprets the value of the field as missing. If a field in SASindicates a missing value (represented by a period), SAS writes anine for each available digit in the corresponding DBF filedatabase field. While in a SAS session a value is represented asmissing if you:

Page 67: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Setting Environment Variables and System Options 59

� fill every available digit in a DBF file field with nines� scroll from the field� return to the field after scrolling

FLOATN,n) specifies a floating-point binary number that is available in dBASEIV and later versions. The maximum N,n value for Float is 20,18.Check with the documentation that comes with other softwareproducts you might be using to create DBF files to determinewhether those products support floating-point binary numbers.

DATE specifies a date value in a format that has numbers and a charactervalue to separate the month, day, and year. The default format ismm/dd/yy. For example, 02/20/95 for February 20, 1995.

Dates in DBF files can be subtracted from one another, with theresult being the number of days between the two dates. A number(of days) can also be added to a date, with the result being a date.

LOGICAL specifies a type that answers a Yes | No or True | False question foreach row in a file. This type is 1 byte long and accepts thesecharacter values: Y, y, N, n, T, t, F, and f.

Note: dBASE also has data types called Memo, General, binary, and OLE. Thesedata types are stored in an associated memo text file (a DBT file), but these data typesare not supported in the SAS/ACCESS Interface to PC Files Server. �

Setting Environment Variables and System Options

MISSINGVALUES

Missing numeric values are filled in with blanks by default. TheDBFMISCH environment variable is used to change the default byspecifying the character that the interface to DBF files uses to fillmissing numeric fields. If you try to write a SAS file with a missingnumeric variable to a DBF file, the corresponding DBF field is filledwith the DBFMISCH character. Conversely, any numeric or floatfield in a DBF file that contains the DBFMISCH character is treatedas a missing value when SAS read it.

You set the DBMISCH environment variable in the SASconfiguration file by using this syntax:

-set DBFMISCH value

Valid values:

any single characterType in any single character. For example, to fill missingnumeric values with the character ’9’, enter -set DBFMISCH 9.

NULLS To replace missing numeric values with binary zeros, enter -setDBFMISCH NULLS.

BLANKS To replace missing numeric values with blanks, enter -setDBFMISCH BLANKS.

DECIMALSEPARATOR

Although the United States uses a decimal separator, othercountries use different symbol characters. For example, someEuropean countries use a comma. You must set theCTRYDECIMALSEPARATOR= system option to enable users toimport or export data that is saved with a different decimal.

Page 68: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

60 Supported SAS IMPORT and EXPORT Procedure Statements � Chapter 6

CTRYDECIMALSEPARATOR= system option syntax:

options CTRYDECIMALSEPARATOR=value;

Any character is valid. For example, to set a comma as thedecimal separator submit this statement in SAS.

options CTRYDECIMALSEPARATOR=’,’ ;

This code uses the period character instead of the commacharacter. To save the numeric values in an exported DBF file whilerunning SAS in a German environment.

options CTRYDECIMALSEPARATOR=’.’;proc export data=sashelp.class

file= "c:\temp\class.dbf"dbms=dbf replace;

run;

Supported SAS IMPORT and EXPORT Procedure StatementsThe IMPORT|EXPORT component uses DBF file formats to access data in DBF

Files on Linux, UNIX, and Microsoft Windows operating environments.The component imports data from DBF files in versions 3, 4, and 5 formats. It

exports data to DBF files with version 5 formats.Examples of Importing and Exporting DBF Files“Example 1: Export Data to a DBF

File from a SAS Data Set” on page 61..

Table 6.11 IMPORT and EXPORT Procedure Statements for DBF Files

DataSource

Syntax Valid Values DefaultValue

PROCIMPORT

PROCEXPORT

DBENCODING= Encoding-value Current SASsessionencoding

Yes YesDBF

GETDELETED= Yes|No Yes Yes No

DBENCODING=12–byte SAS encoding-valueindicates the encoding used to save data in DBF files. Encoding maps eachcharacter in a character set to a unique numeric representation, which results in atable of code points. A single character can have different numeric representationsin different encodings.

For example, some DBF files were saved with pcoem850 encoding. When youare importing these DBF files in Microsoft Windows, specify:

:DBENCODING=pcoem850.The IMPORT procedure reads and transcodes data from pcoem850 to Microsoft

Windows default WLATIN1.Note: Refer to the SAS NLS User’s Guide for information about transcoding and

valid encoding values.

GETDELETED=YES|NOindicates whether to write rows to the SAS data sets that are marked for deletionbut have not been purged.

YES writes rows to the SAS data sets that are marked for deletionand have not been purged.

Page 69: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Supported SAS IMPORT and EXPORT Procedure Statements 61

NO does not write rows to the SAS data sets that are marked fordeletion and have not been purged.

Alias: GETDEL

Example 1: Export Data to a DBF File from a SAS Data Set

This example exports data to a DBF file, named test.dbf, from a SAS data set namedSDF.EMPLOYEE, with a WHERE condition in the data set option.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.EMPLOYEE (where=(HIREDATE is not missing))

OUTFILE="&tmpdir.test.dbf"DBMS=DBF REPLACE;

RUN;

Example 2: Import Data from a DBF File into a SAS Data SetThis example imports data from a DBF file named invoice.dbf into SAS data set

named TEST5. The data is imported without the DELETE flag field.

PROC IMPORT OUT=WORK.TEST5DATAFILE="&dbfdir.Invoice.dbf"DBMS=DBF REPLACE;

GETDEL=NO;RUN;

Example 3: Export Data to a DBF File from a SAS Data Set Using EncodingThis example exports data from a SAS data set named SDF.ORDERS to a DBF file

named Oem850.dbf. The procedure translates SAS data from its current sessionencoding, to pcoem850 encoding and writes it to the DBF file.

PROC EXPORT DATA=SDF.ORDERSOUTFILE="&dbfdir.Oem850.dbf"DBMS=DBF REPLACE;

DBENCODING=pcoem850;RUN;

Example 4: Import and Translate Data from a DBF FileThis example imports data from a DBF file named Oem850.dbf, which was saved

with pcoem850 encoding. The procedure reads in the data and translates it frompcoem850 encoding to current SAS session encoding.

PROC IMPORT OUT=WORK.ORDERSDATAFILE="&dbfdir.Oem850.dbf"DBMS=DBF REPLACE;

DBENCODING=pcoem850;RUN;

Page 70: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

62 dBase DBFMEMO Files � Chapter 6

dBase DBFMEMO Files

OverviewAll versions of dBase under Linux, UNIX, and Microsoft Windows are supported.

Memo files have a .dbt (dBase) or .fpt (FoxPro and Visual FoxPro) file extension. Foxpromemos are stored in a separate directory from dBase memos.

Memo files read blank numeric fields as missing values. Memo files do not havevariables or value labels, and memo support is read-only.

If a memo file exists with the same filename but with a .dbt or .fpt extension, thedriver also reads the memo text for that file. It scans the memo file to determine howmany lines comprise the largest individual memo and the lengths of the longest lines.It then splits memos into one variable per memo line. For example, the first three linesof a memo file called xyz would be named xyz01, xyz02, and xyz03.

Example 1: Import Data from a DBF File with Memo Field into a SAS DataSet

This example imports data from a DBF file named orders.dbf into a SAS data setnamed TEST. The memo field data was saved in the orders.fpt file by Microsoft VisualFoxPro. SAS reads data from both orders.dbf and orders.fpt files.

PROC IMPORT OUT=WORK.TESTDATAFILE="orders.dbf"DBMS=DBF REPLACE;

RUN;

JMP Files

JMP Files EssentialsA JMP file is a file format that the JMP software program creates. JMP is an

interactive statistics package that is available for Microsoft Windows and Macintosh.For more information about a JMP concept or term, see the JMP documentation that ispackaged with your system.

A JMP file contains data that is organized in a tabular format of fields and records.Each field can contain one type of data, and each record can hold one data value foreach field.

Variable names can be up to 31 characters in length. When you are reading a JMPfile, any embedded blank or special character in a variable name is replaced with anunderscore (_). This is noted in the log.

See “Example 1: EXPORT a SAS Data Set to a JMP File” on page 64 .

JMP Missing ValuesJMP supports a single missing value in all variable types other than character. When

you are reading a JMP file, JMP missing value maps to SAS missing value. When youare writing a JMP file, all SAS missing values maps to the single JMP missing value.

Page 71: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � JMP Data Types 63

JMP Data TypesEvery field in a JMP file has a name and a data type. The data type indicates how

much physical storage to set aside for the field and the format in which the data isstored. This list describes each data type.

CHARACTER specifies a field for character string data. The maximum length is255 characters. Characters can be letters, digits, spaces, or specialcharacters.

META specifies how metadata contained in the specified data set is handled.

meta=libref.member

When you add this statement to the EXPORT procedure, themetadata contained in the specified data set is added to the builtJMP file. When you add this statement to the IMPORT procedure,the extra data set that contains the metadata is created whenreading the JMP file.

These record types are processed for the metadata.Table properties:

code="text, subcode="prop", variable="", label=property_text

Variable notes:

code="note", subcode="", variable=varname, label=note_text

You can create any number of properties or notes.

Variable labels are automatically written as SAS labels when theSAS data set is built. SAS variable labels are read when the JMPtable is built.

When you use this statement with the IMPORT procedure, valuelabels from the JMP file can be read and added to the format library.

When you use this statement with the EXPORT procedure, valuelists are read from the format libraries when the JMP table is beingbuilt.

The metadata data set contains these fields: index, number,variable, code, subcode, name, and label. Those names must matchwhen the SAS metadata data set is being read. To do this easily,write the metadata from an existing JMP file to a SAS data set,view the variable information, and record the contents of the file.

NUMERIC specifies an 8–byte floating point number. This is also called adouble precision number. When you are reading data, this mapsdirectly to the SAS double precision number. When you are writingdata, all SAS numeric variables (regardless of length) become JMPnumeric variables.

ROWSTATE specifies an integer variable that takes on the value of 1 or missing.When you are reading data, this maps to a SAS double precisionnumber.

DATE specifies the date format. When you are reading data, the datevalues are mapped to a SAS number and scaled to the base date.The JMP date display format maps to the appropriate SAS datedisplay format. When you are writing data, the SAS output format

Page 72: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

64 Importing and Exporting Data in JMP Files � Chapter 6

for the numeric variable is checked to determine whether it is a dateformat. If so, the SAS numeric value is scaled to a JMP date valuewith the appropriate date display format.

DATETIME specifies the datetime format. When you are reading data, thedatetime values are mapped to a SAS number and scaled to the basedatetime. The JMP datetime display format maps to the appropriateSAS datetime display format. When you are writing data, the SASoutput format for the numeric variable is checked to determinewhether it is a datetime format. If so, the SAS numeric value isscaled to a JMP datetime value with the appropriate datetimedisplay format.

TIME specifies the time format. When you are reading data, the timevalues are mapped to a SAS number and scaled to the base time.The JMP time display format maps to the appropriate SAS timedisplay format. When you are writing data, the SAS output formatfor the numeric variable is checked to determine whether it is a timeformat. If so, the SAS numeric value is scaled to a JMP time valuewith the appropriate time display format.

Importing and Exporting Data in JMP FilesSAS IMPORT|EXPORT utilities provide two components for accessing JMP files.

JMP FileFormats(DBMS=JMP)

This IMPORT| EXPORT component uses JMP file formats to accessdata in JMP files on Linux, UNIX, and Microsoft Windows operatingplatforms. It imports data from JMP files saved with any version ofJMP formats. It exports data to JMP files with V5 formats. Thiscomponent does not provide any additional statements; use the theIMPORT procedure and the EXPORT procedure syntax to accessyour JMP data.

PC Files Server(DBMS=PCFS)

This IMPORT|EXPORT component uses the client server model toaccess data in JMP files on Microsoft Windows from Linux, UNIX, orMicrosoft Windows 64-bit operating environments. This componentrequires running the PC Files Server on Microsoft Windows.

Supported Syntax by the IMPORT Procedure and the EXPORT ProcedureFMTLIB=libref.format-catalog

When importing a JMP file, this saves value labels to the specified SAS formatcatalog. When importing a SAS data set to a JMP file, this writes the specifiedSAS format catalog to the JMP file. User-defined formats.

META=libref.member-data-set;When importing a JMP file, this saves JMP metadata information to the specifiedSAS metadata set. When exporting a SAS data set to a JMP file, this writes thespecified SAS metadata information to the JMP file.Alias: metadata

Example 1: EXPORT a SAS Data Set to a JMP File

This example exports a SAS data set named SDF.CUSTOMER to a JMP file namedcustomer.jmp on a local system.

Page 73: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � Paradox DB File Formats 65

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="&tmpdir.customer.jmp"DBMS=JMP REPLACE;

RUN;

Example 2: IMPORT a SAS Data Set from a JMP FileThis example imports a SAS data set named CUSTOMER from a JMP file named

customer.jmp on a local system.

PROC IMPORT OUT=WORK.CUSTOMERFILE="&jmpdir.customer.jmp"DBMS=JMP REPLACE;

RUN;

Example 3: EXPORT a SAS Data Set on UNIX to a JMP File on MicrosoftWindows

This example exports a SAS data set named SDF.CUSTOMER to a JMP file namedcustomer.jmp. Note that SAS is running on the UNIX operating platform and the JMPfile is loaded on Microsoft Windows where a PC Files Server is running.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="&cstmpdir.customer.jmp"DBMS=PCFS REPLACE;

SERVER=&server;PORT=8621;

RUN;

Example 4: IMPORT Data from a JMP File on Microsoft Windows to a SASData Set on UNIX

This example imports data from a JMP file named customer.jmp to a SAS data setnamed CUSTOMER. Note that SAS is running on a UNIX platform and the JMP file islocated on Microsoft Windows where a PC Files Server is running.

PROC IMPORT OUT= WORK.CUSTOMERFILE="&csjmpdir.customer.jmp"DBMS=PCFS REPLACE;

SERVER=&server;PORT=8621;

RUN;

Paradox DB File Formats

Page 74: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

66 Paradox File Essentials � Chapter 6

Paradox File EssentialsAll versions of Paradox under Linux, UNIX, and Microsoft Windows are supported.

Paradox files have a .db file extension. Paradox supports missing values. It does nothave variables or value labels.

If a memo file with the same filename but with an .db extension exists, the memotext on that file is also read. The memo file is scanned to determine how many linescomprise the largest individual memo and the lengths of the longest lines. The driverthen splits the memos into one variable per memo line. Memo support is read-only.

Example 1: EXPORT a SAS Data Set to a Paradox DB File

This example exports the SAS data set, SDF.CUSTOMER, to the Paradox DB file,customer.db, on a local system.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="&tmpdir.customer.db"DBMS=DB REPLACE;

RUN;

Example 2: IMPORT a SAS Data Set from a Paradox DB FileThis example imports the SAS data set, WORK.CUSTOMER, from the Paradox DB

file, customer.db, on a local system.

PROC IMPORT OUT=WORK.CUSTOMERFILE="&tmpdir.customer.db"DBMS=DB REPLACE;

RUN;

SPSS SAV Files

SAV File EssentialsAll versions of SPSS under Microsoft Windows are supported. SPSS files have a .sav

file extension. SPSS files that have short variable names are exported.See: “Example 1: EXPORT a SAS Data Set to an SPSS SAV File” on page 68.

SPSS Data Types

MISSINGVALUES

SPSS supports missing values. SAS missing values are written asSPSS missing values.

VARIABLENAMES

Only the short variable name style is supported. SPSS variablenames can be up to eight characters in length. All alphabeticcharacters must be uppercase. The first character in a variable

Page 75: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � SPSS Data Types 67

name can be an uppercase letter (A-Z), a dollar sign ($), or an "at"sign (@). Subsequent characters can be any of these characters, plusnumerals (0-9), periods (.), number signs (#), or underscores ( _ ).

SPSS reserves 13 words, which are not allowed to stand alone asvariable names: ALL, AND, BY, EQ, GE, GT, LE, LT, NE, NOT, OR,TO, and WITH. If the program encounters any of these as a variablename, it appends an underscore to the variable name to distinguishit from the reserved word. For example, ALL becomes ALL_.

Invalid characters are converted to underscores unless they areencountered as the first character in a variable name. In that event,the "at" sign (@) is used instead. For example, %ALL becomes @ALL.

When you are exporting to SPSS, SAS variable names that arelonger than eight characters are truncated to eight characters. If thenew name is truncated and results in an existing name, the lastcharacter changes to a single digit (1,2, 3...) until the variable namebecomes unique.

VALUELABELS

SPSS stores value labels within the data file. The values are turnedinto format library entries as they are read with the IMPORTprocedure. The name of the format includes its associated variablename, modified to meet the requirements of format names. Thename of the format is also associated with a variable in the data set.You can use the FMTLIB=libref.format-catalog; statement to savethe formats catalog in a specified SAS library.

The EXPORT procedure saves the value labels that are associatedwith the variables when writing to an SPSS file. The procedure usesthe formats that are associated with the variables to retrieve thevalue entries. You can use the FMTLIB=libref.format-catalogstatement to tell SAS the location of the format catalog.

VARIABLELABELS

SPSS supports variable labels. the EXPORT procedure writes thevariable name to an SPSS file as the label if the variable name isnot a valid SPSS name and no label exists.

DATA TYPES SPSS supports numeric and character field types that map directlyto SAS numeric and character fields. This list shows other SPSSdata types and how the IMPORT procedure converts them to SASformats.

Date, Jdate, Wkday, Qyr, Wkyr: Date, Jdate, Wkday, Qyr, Wkyr

Datetime, Dtime: Converts to a SAS datetime value and SASdatetime format.

Time: Converts to a SAS datetime value and SAS datetimeformat.

Adate: Converts to a SAS date value in the mmddyy format.

Moyr: Converts to a SAS date value in the mmmyy format.

When writing SAS data to an SPSS file, the EXPORT procedureconverts data into SPSS variable types.

When exporting data, character fields have a maximum length of256.

Numeric fields are 8-byte floating-point numbers, with theseformat conversions:

Page 76: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

68 Stata DTA Files � Chapter 6

COMMA Converts to SPSS format type comma.

DOLLAR Converts to SPSS format type dollar.

DATE Converts to SPSS format type date.

MMDDYY Converts to SPSS format Adate.

MMMYY Converts to SPSS format Moyr.

DATETIME Converts to SPSS format Dtime.

TIME Converts to SPSS format Time.

Example 1: EXPORT a SAS Data Set to an SPSS SAV FileThis example exports the SAS data set, SDF.CUSTOMER, to the SPSS SAV file,

customer.sav, on a local system.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="&tmpdir.customer.sav"DBMS=SPSS REPLACE;

RUN;

Example 2: IMPORT a SAS Data Set from an SPSS SAV FileThis example imports the SAS data set, WORK.CUSTOMER, from the SPSS SAV

file, customer.sav, on a local system.

PROC IMPORT OUT=WORK.CUSTOMERFILE="&tmpdir.customer.sav"DBMS=SPSS REPLACE;

RUN;

Stata DTA Files

DTA Files EssentialsAll versions of Stata under Microsoft Windows are supported. Stata files have a .dta

file extension.See “Example 1: EXPORT a SAS Data Set to a Stata DTA File” on page 70 .

DTA Data Types

FILES Import of all Stata versions under Microsoft Windows and UNIX issupported. Export of Stata version 8 and later is supported.

MISSINGVALUES

Stata supports missing values. SAS missing values are written asStata missing values.

VARIABLENAMES

When using importing, Stata variable names can be up to 32characters in length. The first character in a variable name can be

Page 77: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File Format-Specific Reference � DTA Data Types 69

any lowercase letter (a–z) or uppercase letter (A–Z), or anunderscore ( _ ). Subsequent characters can be any of thesecharacters, plus numerals (0–9). No other characters are permitted.Stata reserves these 19 words, which are not allowed to stand aloneas variable names:

_all

in

_pred

_b

int

_rc

_coef

long

_skip

_cons

_n

using

double

_N

_weight

float

pi

with

if

If the program encounters any of these reserved words as variablenames, it appends an underscore to the variable name to distinguishit from the reserved word. For example, _N becomes _N_.

When exporting, variable names greater than 32 characters aretruncated. The first character in a variable name can be anylowercase letter (a–z) or uppercase letter (A–Z), or an underscore ( _). Subsequent characters can be any of these characters, plusnumerals (0–9). No other characters are permitted. Invalidcharacters are converted to underscores ( _ ).

VARIABLELABELS

Stata supports variable labels when using the IMPORT procedure.When exporting, if the variable name is not a valid Stata name andthere is no label, the EXPORT procedure writes the variable nameas the label.

VALUELABELS

Stata stores value labels within the data file. The value labels areconverted to format library entries as they are read with theIMPORT procedure. The name of the format includes its associatedvariable name modified to meet the requirements of format names.The name of the format is also associated with a variable in the SASdata set.

Page 78: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

70 DTA Data Types � Chapter 6

You can use the FMTLIB=libref.format-catalog statement to savethe formats catalog in a specified SAS library. When writing SASdata to a Stata file, the EXPORT procedure saves the value labelsthat are associated with the variables. The procedure uses theformats that are associated with the variables to retrieve the valueentries. You can use the FMTLIB=libref.format-catalog statement totell SAS where to locate the formats catalog.

DATA TYPES Stata supports numeric field types that map directly to SAS numericfields.

Stata date variables become numerics with a date format.

When writing SAS data to a Stata file, the EXPORT procedureconverts data into variable type double. A SAS date format becomesa Stata date variable.

Example 1: EXPORT a SAS Data Set to a Stata DTA File

This example exports the SAS data set, SDF.CUSTOMER, to the Stata DTA file,customer.dta, on a local system.

LIBNAME SDF V9 "&sasdir";PROC EXPORT DATA=SDF.CUSTOMER

FILE="&tmpdir.customer.dta"DBMS=STATA REPLACE;

RUN;

Example 2: IMPORT a SAS Data Set from a Stata DTA FileThis example imports the SAS data set, WORK.CUSTOMER, from the Stata DTA

file, customer.dta, on a local system.

PROC IMPORT OUT=WORK.CUSTOMERFILE="&tmpdir.customer.dta"DBMS=STATA REPLACE;

RUN;

Page 79: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

71

P A R T3

LIBNAME Statement and Pass-ThroughFacility on 32-Bit Microsoft Windows

Chapter 7. . . . . . . . . .The LIBNAME Engines 73

Chapter 8. . . . . . . . . .LIBNAME Statement: PC Files on Microsoft Windows 79

Chapter 9. . . . . . . . . .The Pass-Through Facility for PC Files on MicrosoftWindows 111

Chapter 10. . . . . . . . .File-Specific Reference 127

Page 80: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

72

Page 81: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

73

C H A P T E R

7The LIBNAME Engines

Overview: LIBNAME Engines 73Software Requirements 74

Macro Variables 74

SAS Trace System Options 75

SASTRACE 75

SASTRACELOC 78

Overview: LIBNAME Engines

SAS to Microsoft Ace/Jet LIBNAME Engine

Microsoft Accessdatabase files

SAS to Microsoft AccessLIBNAME Engine

SAS to Microsoft ExcelLIBNAME Engine

MDAC/OLE DB

Microsoft Ace/Jet Provider

Microsoft Excelworkbook files

Page 82: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

74 Software Requirements � Chapter 7

Software Requirements

On Windows, SAS/ACCESS Interface to PC Files supports a LIBNAME engine forMicrosoft Access database files and a LIBNAME engine for Excel workbook files. Thesetwo engines share most of code that calls OLE DB APIs internally. They require thatyou have installed Microsoft Data Access Components (MDAC) and Microsoft Jet (JointEngine Technology) or Microsoft Ace (for 2007 and above) provider software. By default,SAS software installs and checks the required Microsoft software.

Macro Variables

The automatic macro variables SYSDBMSG, SYSDBRC, SQLXMSG, and SQLXRCare portable, but the SAS/ACCESS engine and the Microsoft Jet Engine determinetheir values. Initially, the macro variables SYSDBMSG and SQLXMSG are blank,whereas SYSDBRC and SQLXRC are set to 0.

SAS/ACCESS generates several return codes and error messages while it processesyour programs. This information is available to you through these SAS macro variables:

SYSDBMSGcontains Jet provider-specific error messages that are generated when you useSAS/ACCESS software to access Microsoft Access or Excel data.

SYSDBRCcontains Jet provider-specific error codes that are generated when you useSAS/ACCESS software to Microsoft Access or Excel data. Error codes that arereturned are text, not numbers.

In this statement, %SUPERQ masks special characters such as &, %, and anyunbalanced parentheses or quotation marks that might exist in the text stored in theSYSDBMSG macro.

%put %superq(SYSDBMSG)

These special characters can cause unpredictable results if you use this statement, so itis more advantageous to use %SUPERQ.

You can also use SYMGET to retrieve error messages:

msg=symget("SYSDBMSG");

Here is an example:

data_null_;msg=symget("SYSDBMSG");put msg;run;

The Pass-Through Facility generates return codes and error messages that areavailable to you through these SAS macro variables:

SQLXMSGcontains Jet provider-specific error messages.

SQLXRCcontains Jet provider-specific error codes.

SQLXMSG and SQLXRC can be used only with the Pass-Through Facility. See“Return Codes” on page 112.

Page 83: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The LIBNAME Engines � SASTRACE 75

The contents of the SQLXMSG and SQLXRC macro variables can be printed in theSAS log by using the %PUT macro. SQLXMSG is reset to a blank string and SQLXRCis reset to 0 when any Pass-Through Facility statement is executed.

SAS Trace System OptionsSASTRACE= and SASTRACELOC= are SAS system options that have specific SAS/

ACCESS applications.

SASTRACE

Generates trace information from a DBMS engine

Valid in: OPTIONS statement, configuration file, SAS invocationDefault value: NONE

SyntaxSASTRACE=’,,,d’ | ’,,d,’ | ’d,’ | ’,,,s’

Syntax Description

’,,,d’specifies that all of these SQL statements sent to the Microsoft Jet engine are sent tothe log:

SELECT

UPDATE

CREATE

INSERT

DROP

DELETE

’,,d,’specifies that all routine calls are sent to the log. When this option is selected, allfunction enters and exits, as well as pertinent parameters and return codes, aretraced. However, the information varies from engine to engine.

This option is most useful if you are having a problem and need to send a SAS logto technical support for troubleshooting.

’d,’specifies that all OLE DB API calls for connection information, column bindings,column error information, and row processing are sent to the log. This option is most

Page 84: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

76 SASTRACE � Chapter 7

useful if you are having a problem and need to send a SAS log to technical supportfor troubleshooting.

’,,,s’specifies that a summary of timing information for calls made to the DBMS is sent tothe log.

Note: By default, Microsoft Access and Microsoft Excel LIBNAME engines useROWSET_INSERT instead of executing the SQL INSERT command. You do not see theINSERT statement in the trace log when inserting rows into a table. You can use theLIBNAME statement or the SQL_INSERT=YES option to see the INSERT statement inthe trace log. �

DetailsThe SASTRACE= options have behavior that is specific to SAS/ACCESS software.SASTRACE= is a very powerful tool to use when you want to see the commands thatthe SAS/ACCESS engine sends. SASTRACE= output is DBMS-specific. However, mostSAS/ACCESS engines show statements like SELECT or COMMIT as the DBMSprocesses them for the SAS application. These details can help you manageSASTRACE= output for your files:

� When using SASTRACE= on PC platforms, you must also specify“SASTRACELOC” on page 78.

� To turn SAS tracing off, specify this option:

options sastrace=off;

� Log output is much easier to read if you specify NOSTSUFFIX. Here is an example:

options sastrace=’,,,d’ sastraceloc=saslog nostsuffix;

Example 1. Review SQL StatementsThis example uses SASTRACE =’, , , d’ so that SQL statements can be reviewed.

data work.winter_birthdays;input empid birthdat date9. lastname $18.;format birthdat date9.;

datalines;678999 28DEC1966 PAVEO JULIANA 3451456788 12JAN1977 SHIPTON TIFFANY 3468890123 20FEB1973 THORSTAD EDVARD 3329;run;

options sastrace=’,,,d’ sastraceloc=saslog nostsuffix;LIBNAME mydblib "c:\sasdemo\demo.mdb" ;

proc delete data=mydblib.snow_birthdays; run;

data mydblib.snow_birthdays;set work.winter_birthdays;

run;

proc print data=mydblib.snow_birthdays; run;

Page 85: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The LIBNAME Engines � SASTRACE 77

LIBNAME mydblib clear;

Here are the SQL statements in the SAS log output.

1 data work.winter_birthdays;2 input empid birthdat date9. lastname $18.;3 format birthdat date9.;4 datalines;

NOTE: The data set WORK.WINTER_BIRTHDAYS has 3 observations and 3 variables.NOTE: DATA statement used (Total process time):

real time 0.06 secondsCPU time 0.04 seconds

8 ;9 run;1011 options sastrace=’,,,d’ sastraceloc=saslog nostsuffix;12 LIBNAME mydblib "c:\sasdemo\demo.mdb" ;NOTE: Libref MYDBLIB was successfully assigned as follows:

Engine: ACCESSPhysical Name: c:\sasdemo\demo.mdb

1314 proc delete data=mydblib.snow_birthdays; run;

Jet_0: Executed:DROP TABLE ‘snow_birthdays‘

NOTE: Deleting MYDBLIB.snow_birthdays (memtype=DATA).NOTE: PROCEDURE DELETE used (Total process time):

real time 0.01 secondsCPU time 0.00 seconds

1516 data mydblib.snow_birthdays;17 set work.winter_birthdays;18 run;

NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables.

Jet_1: Executed:CREATE TABLE ‘snow_birthdays‘ (‘empid‘ Double,‘birthdat‘ DateTime,‘lastname‘ VarChar(18))

NOTE: There were 3 observations read from the data set WORK.WINTER_BIRTHDAYS.NOTE: The data set MYDBLIB.snow_birthdays has 3 observations and 3 variables.NOTE: Successfully Inserted 3 row(s)NOTE: DATA statement used (Total process time):

real time 0.03 secondsCPU time 0.01 seconds

Page 86: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

78 SASTRACELOC � Chapter 7

1920 LIBNAME mydblib clear;NOTE: Libref MYDBLIB has been deassigned.

SASTRACELOC

Prints SASTRACE information to a specified location

Valid in: OPTIONS statement, configuration file, SAS invocationDefault value: stdout

SyntaxSASTRACELOC=stdout | SASLOG | FILE ’path-and-filename’

DetailsSASTRACELOC= enables you to specify where to put the trace messages that aregenerated by SASTRACE=. By default, the output goes to the default output locationfor your operating environment. You can send the output to a SAS log by specifyingSASTRACELOC=SASLOG.

Example 1. Write Information to the SAS LogThis example runs on a PC platform and writes trace information to the TRACE.LOGfile in the work directory on the C drive.

options sastrace=’d,,d,d’ sastraceloc=file ’c:\work\trace.log’;

Page 87: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

79

C H A P T E R

8LIBNAME Statement: PC Fileson Microsoft Windows

LIBNAME Statement:PC Files on Microsoft Windows 79Sorting PC Files Data 80

Using SAS Functions with PC Files Data 80

Assigning a Libref Interactively 80

LIBNAME Statement Syntax 81

LIBNAME Options 85Data Set Options 92

AUTOCOMMIT 92

COMMAND_TIMEOUT 92

CURSOR_TYPE 93

DBCOMMIT 94

DBCONDITION 95DBCREATE_TABLE_OPTS 95

DBENCODING 96

DBFORCE 97

DBGEN_NAME 97

DBKEY 98DBLABEL 99

DBMAX_TEXT 100

DBNULL 100

DBNULLKEYS 101

DBSASLABEL 102DBSASTYPE 103

DBTYPE 103

ERRLIMIT 104

INSERT_SQL 105

INSERTBUFF 105

NULLCHAR 106NULLCHARVAL 107

READBUFF 107

SASDATEFMT 108

LIBNAME Statement:PC Files on Microsoft Windows

The SAS/ACCESS LIBNAME statement extends the SAS global LIBNAMEstatement to support assigning a libref to Microsoft Excel files and Microsoft Accessfiles. This enables you to reference spreadsheets and databases directly in a DATA stepor SAS procedure. You can also read from and write to a Microsoft Access object orMicrosoft Excel object as if it were a SAS data set.

Page 88: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

80 Sorting PC Files Data � Chapter 8

Sorting PC Files DataWhen you use the LIBNAME statement to associate a libref with PC files data, you

might observe some behavior that differs from that of normal SAS librefs. Becausethese librefs refer to database and workbook objects, such as tables, they are stored in aformat that differs from the format of normal SAS data sets. This is helpful toremember when you access and work with PC files data.

For example, you can sort the observations in a normal SAS data set and store theoutput to another data set. However, in a Microsoft Access database, sorting data hasno effect on how it is stored. Because your data might not be sorted in the external file,you must sort the data at the time of query. When you sort PC files data, the resultsmight vary. Depending on whether the external spreadsheet or database places datahas NULL values. If the sort encounters NULL values, are they listed at the beginningor end of the result set. NULL values are translated in SAS to missing values.

Using SAS Functions with PC Files DataLibrefs that refer to PC files with SAS functions, might return a different value than

the value returned when you use the functions with normal SAS data sets. ThePATHNAME function might return a Microsoft Excel filename assigned for the libref.For a normal SAS libref, it returns the pathname for the assigned libref.

Other function options can also vary. The LIBNAME function can accept an optionalSAS data-library argument. When you use the LIBNAME function to assign ordeassign a libref that refers to PC files data, you omit this argument. For full detailsabout how to use SAS functions, see the SAS Language Reference: Dictionary.

Assigning a Libref InteractivelyAn easy way to associate a libref with PC files data is to use the New Library user

interface. To access: Issue the DMLIBASSIGN command from the SAS sessioncommand line. You can also access the New Library window by right-clicking thelibraries icon in the Explorer window and selecting New.

Figure 8.1 New Library

Page 89: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Statement Syntax 81

� Name: up to eight alphanumeric characters. The library reference (libref) that youwant to assign. Use the libref to point SAS to a SAS library or an external datasource.

� Engine: select the engine that you want to use. The default engine enables SASto choose which engine to use based on the existing data sets in a library. If nodata sets exists in the same location as your new library, the Base SAS engine isassigned.

� Enable at startup: select to assign the specified libref to automatically whenyou open a SAS session.

� Path: specifies the path of the libref.� Library Information: represents the SAS/ACCESS connection options and vary

according to the SAS/ACCESS engine that you specify. Enter the appropriateinformation for your PC file format.

� OK: click this button to assign the libref, or click Cancel to exit the windowwithout assigning a libref.

LIBNAME Statement Syntax

Associates a SAS libref with a workbook or database.

Valid: Anywhere

SyntaxLIBNAME libref <engine-name> <physical-file-name>

<SAS/ACCESS-engine-connection-options><SAS/ACCESS-LIBNAME-options>;

LIBNAME libref CLEAR|_ALL_ CLEAR;

LIBNAME libref LIST|_ALL_ LIST;

Arguments

librefis any SAS name that serves as an alias to associate SAS with a spreadsheet ordatabase. Like the global SAS LIBNAME statement, the SAS/ACCESS LIBNAMEstatement creates shortcuts or nicknames for data storage locations. A SAS libref isan alias for a virtual or physical directory. A SAS/ACCESS libref for PC files is analias for the spreadsheet or database where your data is stored.

engine-nameis the SAS/ACCESS engine name for your PC file format. The engine name isoptional if physical-file-name is specified. The SAS/ACCESS LIBNAME statementassociates a libref with a SAS/ACCESS engine that supports connections to aparticular PC file. Here are the valid values for engine-name:

EXCEL for Microsoft Excel data (5, 95, 97, 2000, 2002, 2003, or 2007).

ACCESS for Microsoft Access data (97, 2000, 2002, 2003, or 2007).

physical-file-name

Page 90: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

82 LIBNAME Statement Syntax � Chapter 8

is the path and filename, including extension (.xls, .xlsb, .xlsm, .xlsx, .mdb, or.accdb), of the data source.

Note: Omitting the physical-file-name, the engine connection options shouldidentify the data source. You are prompted for a filename, unless PROMPT=NO orNOPROMPT is set in the engine connection options. �

CLEARdisassociates one or more currently assigned librefs.

Specify libref to disassociate a single libref. Specify _ALL_ to disassociate alllibrefs.

_ALL_specifies that the CLEAR or LIST argument applies to all librefs that are currentlyassigned.

LISTwrites the attributes of one or more SAS/ACCESS libraries or SAS libraries to theSAS log.

Specify libref to list the attributes of a single SAS/ACCESS library or SAS library.Specify _ALL_ to list the attributes of all libraries that have librefs in your currentsession.

SAS/ACCESS-engine-connection-optionsprovide connection information to SAS/ACCESS to connect to your PC files. If theconnection options contain characters that are not allowed in SAS names, enclose thevalues of the arguments in quotation marks. In some instances, if you specify theappropriate system options or environment variables for your data source, you canomit the connection options.

See “Connection Options” on page 82 for detailed information about connectionoptions.

SAS/ACCESS-LIBNAME-optionsdefine how SAS interacts with your data source, providing enhanced control of theway that SAS processes data source objects. For example, some LIBNAME optionscan improve performance. For many tasks, you do not need to specify any of theseadvanced options.

See “LIBNAME Statement Syntax” on page 81 for detailed information aboutLIBNAME options.

Connection OptionsSAS/ACCESS provides many ways to connect to your PC files.

INIT "connection-string"specifies an initialization string that SAS uses when connecting to a data source.

Example:

LIBNAME db ACCESS init="Provider=Microsoft.Jet.OLEDB.4.0Data Source=c:\temp\sasdemo.mdb"

Alias: INIT_STRING

Note: This option should not be used with a physical filename or other connectionoptions, such as PATH and UDL

PATH="data-source full-path and file-name"specifies the the full path and filename for the data source file. For the MicrosoftAccess database file or Microsoft Excel workbook file. This option value is treatedthe same as the physical filename. . Use of this option requires the engine name

Page 91: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Statement Syntax 83

to be specified. Always enter file extension .mdb for Microsoft Access and .xls forExcel.

Alias: DATASRC] DS

Note: use this only when the physical filename is not specified in the LIBNAMEstatement

PROMPT=YES|NO |REQUIRED|NOPROMPT|PROMPT|UDLdetermines whether you are prompted for connection information that supplies thedata source information.

YES enables prompting with a Data Link Properties dialog box. Towrite the initialization string to the SAS log, submit this codeimmediately after connecting to the data source:

%put %superq (SYSDBMSG);

NO does not enable prompting with a Data Link Properties dialogbox, and you must specify the data source (physical filename orPATH ).

REQUIRED enables connection without prompting for more informationonly if a valid physical filename is specified for a successfulconnection. Otherwise, you are prompted for the connectionoptions with a dialog box that enables you to change the datasource file and other properties.

NOPROMPT disables prompting with the Data Link Properties dialog box.

PROMPT enables prompting for connection information that supplies thedata source information.

UDL enables browsing so you can select an existing data link file(.udl).

UDL="path-for-udl-file"specifies the path and filename for a UDL file (a Microsoft data link file), as in thisexample:

UDL=’’C:\WinNT\profiles\me\desktop\MyDBLink.UDL’’;%put %superq(SYSDBMSG);

This option does not support SAS filerefs. Macro variable SYSDBMSG is set onsuccessful completion. For more information, refer to Microsoft documentationabout using data link.

Alias: UDL_FILE

Note: this option should not be used with a physical filename or other connectionoptions, such as PATH and INIT.

Details

Using Data from a PC File You can use a LIBNAME statement to read from and writeto a data source table or view as if it were a SAS data set. The LIBNAME statementassociates a libref with a SAS/ACCESS engine to access tables or views in a spreadsheetor database. The SAS/ACCESS engine enables you to connect to a particular datasource and to specify an external data object name in a two-level SAS name.

For example, in MyPCLib.Employees_Q2, MyPCLib is a SAS libref that points to aparticular group of external data objects, and Employees_Q2 is a table name. When youspecify MyPCLib.Employees_Q2 in a DATA step or procedure, you dynamically access

Page 92: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

84 LIBNAME Statement Syntax � Chapter 8

the external data object. SAS supports reading, updating, creating, and deletingexternal data objects dynamically.

Disassociating a Libref from a SAS Library To disassociate or clear a libref, use aLIBNAME statement, specifying the libref (MyPCLib, for example) and this CLEARoption:

LIBNAME mypclib CLEAR;

You can clear a single specified libref or all current librefs.SAS/ACCESS disconnects from the data source and closes any free threads or

resources that are associated with that libref’s connection.

Writing SAS Library Attributes to the SAS Log Use a LIBNAME statement and theLIST option to write the attributes of one or more SAS/ACCESS libraries or SASlibraries to the SAS log. Specify libref to list the attributes of a single SAS/ACCESSlibrary or SAS library, as follows:

LIBNAME mypclib LIST;

Specify _ALL_ to list the attributes of all libraries that have librefs in your currentsession.

Examples

Assigning a Libref with a SAS/ACCESS LIBNAME Statement This statement creates alibref, mymdb, as a Microsoft Access database file:

LIBNAME mymdb "c:\demo.mdb";

The Demo.mdb database contains a number of objects, including several tables, such asStaff. After you assign the libref, you can reference the Microsoft Access table like aSAS data set. You can also use it as a data source in any DATA step or SAS procedure.In this PROC SQL statement, MyMdb.Staff is the two-level SAS name for the Stafftable in the Microsoft Access database Demo.

proc sql;select idnum, lnamefrom mymdb.staffwhere state=’NY’order by lname;

quit;

You can use the Microsoft Access data to create a SAS data set:

data newds;set mymdb.staff(keep=idnum lname fname);

run;

You can also use the libref and data set with any other SAS procedure. Thisstatement prints the information in the Staff table:

proc print data=mymdb.staff;run;

This statement lists the database objects in the MyMdb library:

proc datasets library=mymdb;quit;

This statement associates the SAS libref MYXLS with an Excel workbook:

Page 93: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Options 85

LIBNAME myxls "c:\demo.xls";

See Also

“LIBNAME Statement:PC Files on Microsoft Windows” on page 79

LIBNAME OptionsThe LIBNAME statement options provide enhanced control over the way that SAS

processes PC files data. For many tasks you do not need to specify any of theseadvanced options.

Many of these options are also available as data set options “Data Set Options” onpage 92 .

ACCESS=READONLYindicates that tables and views can be read but not updated.

AUTOCOMMIT=YES|NOdetermines whether the ACCESS engine commits (saves) updates as soon as theuser submits them.Default: NO

YESspecifies that updates are committed to a table as soon as they are submitted,and no rollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commitwhen it reaches the end of the file.

COMMAND_TIMEOUT number-of-secondsspecifies the number of seconds that pass before a data source command times out.

Default: 0 [no time-out]Alias: TIMEOUT

CONNECTION= SHAREDREAD|UNIQUE|GLOBALREADdetermines whether operations against a single libref share a connection to thedata source. Also determines whether operations against multiple librefs share aconnection to the data source.

SHAREDREADspecifies that all READ operations that access data source tables in a singlelibref share a single connection. A separate connection is established for eachtable that is opened for update or output operations.

Where available, this is usually the default value because it offers the bestperformance and it guarantees data integrity.

UNIQUEspecifies that a separate connection is established every time a data sourcetable is accessed by your SAS application.

Use UNIQUE if you want each use of a table to have its own connection.

GLOBALREADspecifies that all READ operations that access data source tables in multiplelibrefs share a single connection if these conditions are met:

Page 94: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

86 LIBNAME Options � Chapter 8

� the participating librefs are created by LIBNAME statements thatspecify identical values for the CONNECTION andCONNECTION_GROUP options

� the participating librefs are created by LIBNAME statements thatspecify identical values for any data source connection options.

A separate connection is established for each table that is opened for updateor output operations.

GLOBALREAD is the default value for CONNECTION when you specifyCONNECTION_GROUP .Default: SHAREDREAD

CONNECTION_GROUP connection-groupcauses operations against multiple librefs to share a connection to the data source.Also causes operations against multiple Pass-Through Facility CONNECTstatements to share a connection to the data source.

CURSOR_TYPE=KEYSET_DRIVEN|STATICspecifies the cursor type for read-only cursors and for cursors to be updated. If youdo not set CURSOR_TYPE= , the Jet provider that you are using determines thedefault.

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set whenyou open the cursor. Changes that are made to these rows are reflected as youmove the cursor. The OLE DB property DBPROP_OTHERUPDATEDELETE=is set as TRUE for key set cursors and FALSE for static cursors.

STATICspecifies that the complete result set is built when you open the cursor, butno changes that are made to the result set are reflected in the cursor. Staticcursors are read-only.

Default: NoneAlias: CURSOR

DBCOMMIT number-of-rowsaffects update, delete, and insert processing. The number of rows that areprocessed includes rows that are not processed successfully. If you setDBCOMMIT= 0, a commit is issued only once (after the procedure or DATA stepcompletes). If the DBCOMMIT= option is explicitly set, SAS/ACCESS fails anyupdate that has a WHERE clause.Default: 1,000 [inserting]

0 [updating; commit occurs when data set or procedure completes]Note: If you specify both DBCOMMIT= and ERRLIMIT=, and these options

collide during processing, DBCOMMIT= is issued first and ERRLIMIT= isissued second. Because the DBCOMMIT= option is issued before theERRLIMIT= option, the DBCOMMIT= option overrides the ERRLIMIT= optionin this situation.

DBENCODING=12–byte SAS encoding-valueindicates the encoding used to save data in DBF files. Encoding maps eachcharacter in a character set to a unique numeric representation, which results in atable of code points. A single character can have different numeric representationsin different encodings.

For example, some DBF files were saved with pcoem850 encoding. When youare importing these DBF files in Microsoft Windows, specify:

Page 95: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Options 87

:DBENCODING=pcoem850.The IMPORT procedure reads and transcodes data from pcoem850 to Microsoft

Windows default WLATIN1.

Note: Refer to the SAS NLS User’s Guide for information about transcoding andvalid encoding values.

DBGEN_NAME=DBMS|SASspecifies that the data source columns are renamed and the format used for thenames.

DBMSspecifies that the data source columns are renamed to valid SAS variablenames. Disallowed characters are converted to underscores. If a column isconverted to an existing name, then a sequence number is appended to thenew name.

SASspecifies that data source columns are renamed to the format _COLn, wheren is the column number (starting with zero).

Default: DBMS

DBMAX_TEXT=nspecifies an integer between 1 and 32,767 that indicates the maximum length for acharacter string. Longer character strings are truncated. This option only applieswhen you are reading, appending, and updating character data in a MicrosoftAccess database or Excel workbook from SAS. Although you can specify a value lessthan 256, it is not recommended for reading data from Microsoft Access database.

Default: 1,024

DBNULLKEYS=YES|NOto specify that there might be NULL values in the columns.

YESif you specify NOT NULL in the DBKEY= option, and there might be NULLvalues in a column, specify DBNULLKEYS=YES. SAS generates a WHEREclause to find NULL values. If you specify DBNULLKEYS=YES and acolumn not defined NOT NULLDBKEY data set option, SAS generates aWHERE clause to find NULL values. If

you specify DBKEY=COLUMN and COLUMN is not defined as NOTNULL, SAS generates a WHERE clause with this syntax:

WHERE ((COLUMN = ?) OR ((COLUMN IS NULL) AND (? IS NULL)));

NOWhen you specify DBNULLKEYS=NO or specify a column that is defined asNOT NULL in the DBKEY= option, SAS generates a simple WHERE clause.If you know that there are no NULL values in the transaction or the mastertable for the columns specified in the DBKEY= option, useDBNULLKEYS=NO.

If you specify DBNULLKEYS=NO and specify DBKEY=COLUMN, SASgenerates a shorter form of a WHERE clause. The WHERE clause isgenerated regardless of whether the column that DBKEY= specifies is definedas NOT NULL:

WHERE (COLUMN = ?)

Page 96: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

88 LIBNAME Options � Chapter 8

Note: This syntax enables SAS to prepare the statement once and use it forany value (NULL or NOT NULL) in the column. �Default: YES

DBSASLABEL=COMPAT|NONEspecifies whether SAS/ACCESS saves the data source column names as SAS labelnames. This option is valid only when reading data into SAS from the data source.

COMPATspecifies that the data source column names are saved as SAS label names.This is compatible to the previous SAS releases.

NONEspecifies that the data source column names are not saved as SAS labelnames. SAS label names are left as null values.

Default: COMPAT

DEFER=NO|YESlets you specify when the connection to the data source occurs.

NOspecifies that the connection to the data source occurs when the libref isassigned by a LIBNAME statement.

YESspecifies that the connection to the data source occurs when a table in thedata source is opened.

Default: NO

DIRECT_SQL=YES|NO|NONE specific-functionalityenables you to specify whether generated SQL is passed to the data source forprocessing.

YESspecifies that, whenever possible, generated SQL, except multiple outer joins,is passed to the data source for processing. This includes SQL that isgenerated from PROC SQL, SAS functions that can be converted into datasource functions, joins, and WHERE clauses.

NOspecifies that generated SQL from PROC SQL is not passed to the datasource for processing. This is the same as specifying the specific-functionalityvalue NOGENSQL.

NONEspecifies that generated SQL is not passed to the data source for processing.This includes SQL that is generated from PROC SQL, SAS functions that canbe converted into data source functions, joins, and WHERE clauses.

specific-functionalityidentifies types of processing to be handled by SAS instead of the datasource. You can specify these values:

NOFUNCTIONScauses SAS to handle all SAS functions. The SAS functions are notconverted into data source functions and are not passed to the datasource for processing.

NOMULTOUTJOINScauses SAS to process outer joins that involve more than two tables.Note: this option is always turned ON for the Microsoft Jet engine.

Page 97: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Options 89

Restriction: this option does not affect outer joins of two tables.

NOGENSQLprevents PROC SQL from generating SQL to be passed to the datasource for processing.

NOWHEREprevents WHERE clauses from being passed to the data source forprocessing. This includes SAS WHERE clauses and PROC SQLgenerated or PROC SQL specified WHERE clauses.

Default: YES

FILELOCK= YES|NOdetermines the type of access to the Microsoft Excel file. By default, FILELOCK isnot set. SAS does not check whether the Excel file was opened by Excel or anotherapplication when you assign a LIBNAME statement for the file. A potential accessviolation can occur if a user attempts to update the Excel file using MicrosoftExcel. Specifying FILELOCK=YES indicates that the LIBNAME engine checksand denies the connection if the file was opened by Excel or another application.

YES: enables only one LIBNAME assignment with READ and WRITEpermission to connect to the file. The LIBNAME assignment is denied if the filehas been opened by Excel or another application.

NO: specifies that the Microsoft Excel LIBNAME engine behaves the same as inSAS 9.1.

Restriction: applies only to the Microsoft Excel LIBNAME engine; has no effecton the Microsoft Access LIBNAME engine.

Enables other applications to open the Excel file with READONLYpermission to connect to the file. The LIBNAME statement is: READONLYLIBNAME, set FILELOCK=YES with ACCESS=READONLY. This enablesother applications to open the Excel file in READONLY mode with connectioninformation set to browse data.

INSERT_SQL= YES|NOdetermines the method that is used to insert rows into a data source.

YES specifies that the SAS/ACCESS engine uses the data source’sSQL insert method to insert new rows into a table.

NO specifies that the SAS/ACCESS engine uses an alternate (datasource-specific) method to add new rows to a table.

Default: NO

INSERTBUFF=number-of-rowsspecifies the number of rows for a multiple-row insert. If the INSERTBUFF valueis greater than the DBCOMMIT value, the DBCOMMIT value overrides theINSERTBUFF value. Microsoft ACCESS only. The value for INSERTBUFF= mustbe a positive number.

Default: 1

Note: If you assign a value that is greater than INSERTBUFF=1, the SAS notesthat indicate the success or failure of the insert operation might be incorrect.The SAS notes only represent information for a single insert, even whenmultiple inserts are performed.

MSENGINE= ACE|JET

Page 98: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

90 LIBNAME Options � Chapter 8

determines the database engine used for accessing the Microsoft Excel file or theMicrosoft Access database. The Microsoft Jet engine is older and supports formatsup to 2003. The Microsoft Ace engine supports 2007 and older formats.

Restriction: It is recommended that you do not use this file option unless youare trying to create a 95 format file.

Default: ACE

READBUFF=number-of-rowsspecifies the number of rows of data to read. Setting a higher value for this optionreduces I/O and increases performance, and increases memory usage. Additionally,if too many rows are read at once, values returned to SAS might be out of date.

Alias: ROWSET|ROWSET_SIZE

Default: 1

Restriction: Microsoft ACCESS only.

SCAN_TEXTSIZE=YES|NOspecifies whether to scan the length of text data for a data source column and usethe length of the longest string data found as the SAS column width. ForMicrosoft Excel, this option applies to all character data type columns. ForMicrosoft Access, this option only applies to the MEMO data type field, it does notapply to the TEXT (less than 256 characters long) field.

YES scans the length of text data for a data source column. Sets thelength of the longest string of data, as the SAS variable length.If the maximum SCAN_TEXT length is greater than themaximum DBMAX_TEXT length, the DBMAX_TEXT value isset as the SAS variable length. Default for Microsoft Excelworkbook.

NO does not scan the length of text data for a data source column.The column length that is returned from the Microsoft Jetprovider is set as the SAS variable length. If the length that isreturned from the Microsoft Jet provider is greater than theDBMAX_TEXT value, the smaller value is set as the SASvariable lengths. Specify SCANTEXT=NO when you need toupdate data in the Microsoft Access database or the MicrosoftExcel workbook.

Alias: SCAN_TEXT|SCANTEXT|SCANMEMO

SCAN_TIMETYPE=YES| NO|ANYspecifies whether to scan all row values for a DATETIME data type field andautomatically determine the TIME data type based on the setting. Option valuesYES and ANY turn on the scan function. Option value NO turns off the scanfunction.

YES specifies that a column with all time values (internal value isless than 1) is assigned a TIME8. format.

NO the default, specifies that a column with date/time values isassigned the DATE9. format or the DATETIME19. format.

ANY specifies that a column with any (one or more) time values areassigned a TIME8. format.

See also: USE_DATETYPE

Restriction: available only for Microsoft Windows

Default: NO

Page 99: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � LIBNAME Options 91

SPOOL=YES|NOspecifies whether SAS creates a utility spool file during read transactions thatread data more than once.

YES specifies that SAS creates a utility spool file into which itwrites the rows that are read the first time. For subsequentpasses through the data, the rows are read from the utilityspool file rather than being reread from the data source table.This guarantees that the row set is the same for every passthrough the data

NO specifies that the required rows for all passes of the data areread from the data source table. No spool file is written. Thereis no guarantee that the row set is the same for each passthrough the data.

Default: YES

STRINGDATES=YES|NOspecifies whether datetime values are read from the data source as characterstrings or as numeric date values. STRINGDATES is not available as a data setoption.

NO specifies that SAS/ACCESS reads datetime values as numericdate values.

YES specifies that SAS/ACCESS reads datetime values as characterstrings.

Default: NO

Alias: STRDATES

UNICODE=YES|NOdetermines whether the LIBNAME engine binds the character data type columnswith narrow or wide character mode. This option supersedes the DBENCODINGoption. For DBCS (Chinese, Korean, and Japanese) users, it is recommended touse this option instead of the DBENCODING= option.

YES specifies that SAS binds the character type columns with widecharacter mode. This allows some character data such asDBCS to be returned correctly. This setting works the same assetting DBENCODING="UTF-16".

NO specifies that SAS binds the character type columns withnarrow character mode.

Default: NO

USE_DATETYPE=YES|NOspecifies whether to assign the DATE. format for datetime columns in the datasource table while importing data from Microsoft Access database or Excelworkbook.

YES specifies that the DATE. format is assigned for datetimecolumns in the data source table.

NO specifies that the DATETIME. format is assigned for datetimecolumns in the data source table

Alias: USE_DATE|USEDATE

Default: YES for Microsoft Excel workbooks.

Default: NO for Microsoft Access databases

Page 100: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

92 Data Set Options � Chapter 8

Data Set OptionsYou can specify SAS/ACCESS data set options on a SAS data set when you access PC

files data with the LIBNAME statement. A data set option applies only to the data seton which it is specified, and it remains in effect for the duration of the DATA step orprocedure.

This generic example illustrates the format of data set options:

LIBNAME libref engine-name;PROC PRINT libref.data-set-name(DATA_SET_OPTION=value)

You can use the CNTLLEV=, DROP=, FIRSTOBS= , IN=, KEEP=, OBS=, RENAME=,and WHERE SAS data set options when you access PC files data. SAS/ACCESSinterfaces do not support the REPLACE SAS data set option. For information aboutusing SAS data set options, refer to the SAS Language Reference: Dictionary.

Note: Specifying data set options in PROC SQL might reduce performance, becauseit prevents operations from being passed to the data source for processing. �

AUTOCOMMIT

Determines whether the ACCESS engine commits (saves) updates as soon as the user submitsthem.

Valid in: DATA and PROC stepsDefault: LIBNAME option setting

SyntaxAUTOCOMMIT=YES|NO

Syntax Description

YESspecifies that updates are committed to a table as soon as they are submitted, and norollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commit when itreaches the end of the file.

COMMAND_TIMEOUT

Specifies the number of seconds to wait before a command times out.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Page 101: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � CURSOR_TYPE 93

Default value: LIBNAME option setting

SyntaxCOMMAND_TIMEOUT=number-of-seconds

See AlsoTo assign this option to a group of tables, use the COMMAND_TIMEOUT option

specified in “LIBNAME Options” on page 85.

CURSOR_TYPESpecifies the cursor type for read-only cursors and for cursors to be updated.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: LIBNAME option setting

SyntaxCURSOR_TYPE=KEYSET_DRIVEN|STATIC

Syntax Description

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set when thecursor is opened. However, changes that are made to these rows are reflected as youmove the cursor.

STATICspecifies that the cursor builds the complete result set when the cursor is opened. Nochanges made to the rows in the result set after the cursor is opened are reflected inthe cursor. Static cursors are read-only.

DetailsBy default, this option is not set, and the Microsoft Jet provider uses a default. TheOLE DB properties applied to an open row set are as follows:

CURSOR_TYPE= OLE DB Properties Applied

KEYSET_DRIVENDBPROP_OTHERINSERT=FALSE,DBPROP_OTHERUPDATEDELETE=TRUE

STATICDBPROP_OTHERINSERT=FALSE,DBPROP_OTHERUPDATEDELETE=FALSE

Page 102: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

94 DBCOMMIT � Chapter 8

See your OLE DB programmer reference documentation for details about theseproperties.

See AlsoTo assign this option to a group of tables, use the CURSOR_TYPE option specified in

“LIBNAME Options” on page 85.

DBCOMMIT

Enables you to issue a commit statement automatically after a specified number of rows havebeen processed.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: LIBNAME option setting

SyntaxDBCOMMIT=number-of-rows

Syntax Description

number-of-rowsis an integer greater than or equal to 0.

DetailsDBCOMMIT affects update, delete, and insert processing. The number of rowsprocessed includes rows that are not processed successfully. When DBCOMMIT=0, acommit is issued only once after the procedure or DATA step completes.

If the DBCOMMIT option is explicitly set, SAS/ACCESS fails any update that has aWHERE clause.

To assign this option to a group of tables, use the DBCOMMIT option specified in“LIBNAME Options” on page 85.

Note: If you specify both DBCOMMIT = option and an ERRLIMIT= option, andthese options collide during processing, then the commit is issued first and the rollbackis issued second. Because the DBCOMMIT= option is issued before the ERRLIMIT =option, the DBCOMMIT = option overrides the ERRLIMIT= option in this situation. �

Example 1.

/* a commit is issued after every 10 rows are inserted */data myxls.dept(dbcommit=10);set mysas.staff;run;

Page 103: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � DBCREATE_TABLE_OPTS 95

DBCONDITION

Specifies criteria for subsetting and ordering data.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: none

SyntaxDBCONDITION="SQL-query-clause"

Syntax Description

SQL-query-clauseis a data source-specific SQL query clause, such as WHERE, GROUP BY, HAVING,or ORDER BY.

DetailsThis option enables you to specify selection criteria in the form of data source-specificSQL query clauses, which the SAS/ACCESS engine passes directly to the data sourcefor processing. When selection criteria are passed directly to the data source forprocessing, performance is often enhanced. The data source checks the criteria forsyntax errors when it receives the SQL query.

The DBKEY option is ignored when you use DBCONDITION.

DBCREATE_TABLE_OPTS

Specifies data source-specific syntax to be added to the CREATE TABLE statement.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: LIBNAME option setting

SyntaxDBCREATE_TABLE_OPTS=’SQL-clauses’

Syntax Description

SQL-clausesare one or more data source-specific clauses that can be appended to the end of anSQL CREATE TABLE statement.

Page 104: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

96 DBENCODING � Chapter 8

DetailsThis option enables you to add data source-specific clauses to the end of the SQLCREATE TABLE statement. The SAS/ACCESS engine passes the SQL CREATETABLE statement and its clauses to the data source, which executes the statement andcreates the table.

See AlsoTo assign this option to a group of tables, use the DBCREATE_TABLE_OPTS option

specified in “LIBNAME Options” on page 85.

DBENCODING

Specifies the encoding character set to use in the Microsoft Access database or in the MicrosoftExcel workbook.

Valid in: DATA and PROC steps.Default Value: NONE

SyntaxDBENCODING=12–byte SAS encoding-value

Syntax DescriptionThe 12–byte SAS encoding-value is an encoding value that SAS defines. It can be up

to 12 characters long. For a list of valid values, see the section “Encoding Values in SASLanguage Elements” in SAS National Language Support Reference Guide.

DetailsSpecify the encoding character set to use in your Microsoft Access database or Excel

workbook file. This option enables SAS to transcode character data between the SASsession encoding and the DBENCODING value.

It is recommended that you use UNICODE = YES instead of DBENCODING. SettingUNICODE=YES is equivalent to setting DBENCODING=’UTF-16’.

This enables SAS to bind text in wide character format. SAS is also enabled totranscode data between a SAS session-for example, Chinese BIG5 encoding, and Accessor Excel in Unicode encoding. In a UTF-8 session, SAS assumes that UNICODE=YES.

Transcoding is a process that converts text data from one encoding to anotherencoding. Note

� it does not translate from one language to another language� it does not translate the English language to the Japanese language� it does not translate the Chinese language to the Japanese language� it might map some Chinese characters to Japanese Hanzi characters

Page 105: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � DBGEN_NAME 97

DBFORCE

Specifies whether to force the truncation of data during insert processing.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: NO

SyntaxDBFORCE=YES|NO

Syntax Description

YESspecifies that the rows that contain data values that exceed the length of the columnare inserted, and the data values are truncated to fit the column length.

NOspecifies that the rows that contain data values that exceed the column length arenot inserted.

DetailsThis option determines how the SAS/ACCESS engine handles rows that contain datavalues that exceed the length of the column.

The SAS data set option FORCE overrides this option when it is used with PROCAPPEND or the PROC SQL UPDATE statement. The PROC SQL UPDATE statementdoes not provide a warning before truncating the data.

DBGEN_NAME

Specifies whether to rename columns automatically when they contain disallowed characters.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: LIBNAME option setting

SyntaxDBGEN_NAME=DBMS|SAS

Syntax Description

DBMS

Page 106: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

98 DBKEY � Chapter 8

specifies that disallowed characters are converted to underscores.

SASspecifies that columns that contain disallowed characters are converted into validSAS variable names, using the format _COLn, where n is the column number(starting with zero). If a name is converted to a name that already exists, a sequencenumber is appended to the end of the new name.

DetailsSAS retains column names when reading data, unless a column name containscharacters that SAS does not allow, such as $ or @. SAS allows alphanumericcharacters and the underscore (_).

This option is intended primarily for National Language Support. Notably theconversion of kanji to English characters. The English characters converted from kanjiare often not allowed in SAS. If you specify DBGEN_NAME=SAS, a column namedDEPT$AMT is renamed to _COLn where n is the column number. If you specifyDBGEN_NAME=DBMS, a column named DEPT$AMT is renamed to DEPT_AMT.

See AlsoTo assign this option to a group of tables, use the DBGEN_NAME option specified in

“LIBNAME Options” on page 85.

DBKEY

Improves performance for a join with a large data source table and a small SAS data set(specifies a column to use as an index).

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: none

SyntaxDBKEY=(<’>column-1<’> <... <’>column-n<’>>)

Syntax Description

columnis the name of the column that forms the index on the data source table.

DetailsWhen processing a join that involves a large data source table and a relatively smallSAS data set, you might be able to use DBKEY to improve performance.

CAUTION:Improper use of this option can harm performance. �

Page 107: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � DBLABEL 99

DBLABEL

Specifies whether to use SAS variable labels as data source column names during outputprocessing.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: NO

Syntax

DBLABEL=YES|NO

Syntax Description

YESspecifies that SAS variable labels are used as data source column names duringoutput processing.

NOspecifies that SAS variable names are used as data source column names.

Details

this option is valid only for creating data source tables.No more than 64 characters of SAS variable labels are written to Microsoft Access or

Microsoft Excel files.

Example

In this example, the SAS data set New is created with one variable C1. It is assigneda label of DeptNum. In the second DATA step, the MyDBLib.MyDept table is created byusing DeptNum as the data source column name. By setting DBLABEL=YES, you canuse the label as the column name.

data new;label c1=’deptnum’;c1=001;run;

data mydblib.mydept(dblabel=yes);set new;run;

proc print data=mydblib.mydept;run;

Page 108: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

100 DBMAX_TEXT � Chapter 8

DBMAX_TEXT

Determines the length of a very long data source character data type that is read into SAS orwritten from SAS when you are using a SAS/ACCESS engine.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: LIBNAME option setting

SyntaxDBMAX_TEXT= integer

Syntax Description

integeris a number between 1 and 32,767.

DetailsThis option applies to reading, appending, and updating rows in an existing table. Itdoes not apply when you are creating a table.

DBMAX_TEXT is usually used with a very long character data type.Although you can specify a value less than 256, it is not recommended for reading

data from Microsoft Access database.

See AlsoTo assign this option to a group of tables, use the DBMAX_TEXT option specified in

“LIBNAME Options” on page 85.

DBNULL

Indicates whether NULL is a valid value for the specified columns when a table is created.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: YES

SyntaxDBNULL= (column-name-1=YES|NO <...column-name-n=YES|NO >

|_ALL_=YES|NO)

Syntax Description

Page 109: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � DBNULLKEYS 101

YESspecifies that the NULL value is valid for the specified columns.

NOspecifies that the NULL value is not valid for the specified columns.

Detailsthis option is valid only for creating data source tables. If you specify more than onecolumn name, the names must be separated with spaces.

The DBNULL option processes values from left to right. If you specify a columnname twice, or if you use the _ALL_ value, the last value overrides the first valuespecified for the column.

Note: only the Access engine—not the Excel engine—supports this option.

Examples

In this example, using the DBNULL option prevents the EmpId and Jobcode columnsin the new MyDBLib.MyDept2 table from accepting null values. If the Employees tablecontains null values in the EmpId or Jobcode columns, the DATA step fails.

data mydblib.mydept2(dbnull=(empid=no jobcode=no));set mydblib.employees;run;

In this example, all columns in the new MyDBLib.MyDept3 table except for theJobcode column are prevented from accepting null values. If the Employees tablecontains null values in any column other than the Jobcode column, the DATA step fails.

data mydblib.mydept3(dbnull=(_ALL_=no jobcode=YES));set mydblib.employees;run;

DBNULLKEYS

Controls the format of the WHERE clause when you use the DBKEY data set option.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: LIBNAME setting

SyntaxDBNULLKEYS= YES|NO

DetailsIf there might be NULL values in the transaction table or the master table for thecolumns that you specify in the DBKEY option, then use DBNULLKEYS=YES. Whenyou specify DBNULLKEYS=YES, and specify a column that is not defined as DBKEY=

Page 110: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

102 DBSASLABEL � Chapter 8

NOT NULL, SAS generates a WHERE clause that finds NULL values. For example, ifyou specify DBKEY=COLUMN and COLUMN is not defined as NOT NULL, SASgenerates a WHERE clause with this syntax:

WHERE ((COLUMN = ?) OR ((COLUMN IS NULL) AND (? IS NULL)))

This syntax enables SAS to prepare the statement once and use it for any value (NULLor NOT NULL) in the column. Note that this syntax has the potential to be much lessefficient than the shorter form of the WHERE clause (presented below). When youspecify DBNULLKEYS=NO or specify a column that is defined as NOT NULL in theDBKEY option, SAS generates a simple WHERE clause.

If there are no NULL values in the transaction table or the master table for thecolumns listed in the DBKEY option, use DBNULLKEYS=NO. If you specifyDBNULLKEYS=NO and DBKEY=COLUMN, SAS generates a shorter form of theWHERE clause. This WHERE clause is generated even if the column that DBKEYspecifies is defined as NOT NULL.

WHERE (COLUMN = ?)

See AlsoTo assign this option to a group of tables, use the DBNULLKEYS option specified in

“LIBNAME Options” on page 85.

DBSASLABEL

Specifies whether SAS/ACCESS saves the data source’s column names as SAS label names.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: COMPAT

SyntaxDBSASLABEL= COMPAT| NONE

Syntax Description

COMPATspecifies that SAS/ACCESS saves the data source’s column names as SAS labelnames. This is compatible to the previous SAS releases.

NONEspecifies that SAS/ACCESS does not save the data source’s column names as SASlabel names. SAS label names are left as NULLs.

Detailsthis option is valid only while you are reading data into SAS from the data source.

Page 111: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � DBTYPE 103

DBSASTYPE

Specifies data type(s) to override the default SAS data type(s) during input processing of data.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: none

SyntaxDBSASTYPE=(column-name-1=<’>SAS data-type<’> <...column-name-n=<’>SAS

data-type<’>>)

Syntax Description

column-namespecifies a data source column name.

SAS data-typespecifies a SAS data type. SAS data types include CHAR(n), NUMERIC,DATETIME, DATE, TIME.

DetailsBy default, SAS/ACCESS converts each data source data type to a SAS data typeduring input processing. When you need a different data type, you can use this optionto override the default and assign a SAS data type to each specified data source column.Some conversions might not be supported. If a conversion is not supported, SAS printsan error to the log.

DBTYPE

Specifies a data type to use instead of the default data source data type when SAS creates a datasource table.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: none

SyntaxDBTYPE=(column-name-1=<’>data-source-type<’>

<...column-name-n=<’>data-source-type<’>>)

Syntax Description

Page 112: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

104 ERRLIMIT � Chapter 8

column-namespecifies a data source column name.

data-source-typespecifies a data source data type. See the documentation for your SAS/ACCESSinterface for the default data types for your data source.

DetailsBy default, SAS/ACCESS converts each SAS data type to a predetermined data sourcedata type when outputting data to your data source. When you need a different datatype, use DBTYPE to override the default data type chosen by the SAS/ACCESS engine.

Example

In this example, DBTYPE specifies the data types that are used when you createcolumns in the table.

data mydblib.newdept(dbtype=(deptno=’double’ city=’char(25)’));set mydblib.dept;run;

ERRLIMIT

Specifies the number of errors that are allowed before SAS stops processing and issues a rollback.

Valid in: DATA and PROC steps when accessing PC files data using SAS/ACCESS.

Default value: 1

SyntaxERRLIMIT integer

Syntax Description

integeris a positive integer that represents the number of errors after which SAS stopsprocessing and issues a rollback.

DetailsSAS calls the data source to issue a rollback after a specified number of errors occursduring the processing of inserts, deletes, updates, and appends. If ERRLIMIT is set to0, SAS processes all rows, regardless of the number of errors that occur. The SAS logdisplays the total number of rows processed and the number of failed rows, if applicable.

The DBCOMMIT option overrides the ERRLIMIT option. If you specify aDBCOMMIT value other than zero, then the ERRLIMIT option might not include

Page 113: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � INSERTBUFF 105

records that are processed unsuccessfully. This is because they were already committedin the DBCOMMIT option.

Note: DBCOMMIT cannot be used from a SAS client session in a SAS/SHAREenvironment. �

Example

/*MyDBLib libref was assigned in a prior LIBNAME statement*/./*SAS stops processing at the occurrence of the tenth error data */mydblib.employee3 (errlimit=10); set mydblib.employees; where salary > 40000; run;

INSERT_SQL

Determines the method that is used to insert rows into a data source.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: LIBNAME option setting

SyntaxINSERT_SQL=YES|NO

Syntax Description

YESspecifies that the SAS/ACCESS engine uses the data source’s SQL insert method toinsert new rows into a table.

NOspecifies that the SAS/ACCESS engine uses an alternate data source-specific methodto add new rows to a table.

See AlsoTo assign this option to a group of tables, use the INSERT_SQL option specified in

“LIBNAME Options” on page 85.

INSERTBUFF

Specifies the number of rows in a single insert.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Page 114: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

106 NULLCHAR � Chapter 8

Default value: LIBNAME option setting

SyntaxINSERTBUFF=number-of-rows

Syntax Description

number-of-rowsspecifies the number of rows to insert. The value must be a positive integer.Restriction: Microsoft Access only

DetailsSAS allows the maximum number of rows that is allowed by the data source. Theoptimal value for this option varies with factors such as network type and availablememory. You might need to experiment with different values to determine the bestvalue for your site.

If you assign a value that is greater than INSERTBUFF=1, SAS notes the indicationof success or failure of the insert operation might be incorrect. The notes only representinformation for a single insert, even when multiple inserts are performed.

If the DBCOMMIT option is specified with a value that is less than the value ofINSERTBUFF, then DBCOMMIT overrides INSERTBUFF.

Note: When inserting with the VIEWTABLE window, the FSEDIT, or FSVIEWprocedure, use INSERTBUFF=1 to prevent the data source interface from trying toinsert multiple rows. These features do not support inserting more than one row at atime. �

See AlsoTo assign this option to a group of tables, use the INSERTBUFF option specified in

“LIBNAME Options” on page 85.

NULLCHARIndicates how SAS character missing values are handled during insert, update, and DBKEYprocessing.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: YES

SyntaxNULLCHAR= YES|NO

Syntax Description

Page 115: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � READBUFF 107

YESindicates that character missing values in SAS data sets are treated as NULL valuesif the data source allows them. Otherwise, an error is returned.

NOindicates that character missing values in SAS data sets are treated as theNULLCHARVAL value (regardless of whether the data source allows NULLs for thecolumn).

DetailsThis option affects insert and update processing and also applies when you use theDBKEY option.

This option works in conjunction with the NULLCHARVAL data set option, whichdetermines what is inserted when NULL values are not allowed.

All SAS numeric missing values (represented in SAS as ’.’) are treated by the datasource as NULLs.

NULLCHARVAL

Defines the character string that replaces SAS character missing values during insert, update, andDBKEY processing.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)Default value: a blank character

SyntaxNULLCHARVAL=’character-string’

DetailsThis option affects insert and update processing and also applies when you use theDBKEY option.

This option works with the NULLCHAR option, which determines whether a SAScharacter NULL value is treated as a NULL value.

If NULLCHARVAL is longer than the maximum column width, one of these actionsoccurs:

� the string is truncated if DBFORCE=YES� the operation fails if DBFORCE=NO.

READBUFF

Specifies the number of rows of data to read into the buffer.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Page 116: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

108 SASDATEFMT � Chapter 8

Default value: LIBNAME option setting

SyntaxREADBUFF=number-of-rows

Syntax Description

number-of-rowsis the maximum value that is allowed by the data source.

Restriction: Microsoft Access only

DetailsThis option improves performance by specifying a number of rows that can be held inmemory for input into SAS. Buffering data reads can decrease network activities andincrease performance. However, because SAS stores the rows in memory, higher valuesfor READBUFF use more memory. In addition, if too many rows are selected at once,then the rows that are returned to the SAS application might be out of date.

When READBUFF=1, only one row is retrieved at a time. The higher the value forREADBUFF , the more rows the SAS/ACCESS engine retrieves in one fetch operation.

ROWSET_SIZE is an alias for this option.

See AlsoTo assign this option to a group of tables, use the READBUFF option specified in

“LIBNAME Options” on page 85.

SASDATEFMT

Changes the SAS date format of a data source column.

Valid in: DATA and PROC steps (when accessing PC files data using SAS/ACCESSsoftware)

Default value: none

SyntaxSASDATEFMT=(data-source-date-column-1= ’SAS date-format’

<... data-source-date-column-n=’SAS date-format’>)

Syntax Description

data-source date-columnspecifies the name of a date column in a data source table.

Page 117: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Microsoft Windows � SASDATEFMT 109

SAS date-formatspecifies a SAS date format that has an equivalent, like-named informat.

EXAMPLEDATETIME21.2 is both a SAS format and a SAS informat. It is a valid value for

the SAS date-format argument.

DetailsIf the date format of a SAS column does not match the date format of the correspondingdata source column, use the SASDATEFMT option to convert date values. TheSASDATEFMT option enables you to convert date values from the default SAS dateformat to another SAS date format that you specify.

Use the SASDATEFMT option to prevent date type mismatches under thesecircumstances:

� during input operations to convert data source date values to the correct SASDATE, TIME, or DATETIME values

� during output operations to convert SAS DATE, TIME, or DATETIME values tothe correct data source date values

Default:The default SAS date format is data source-specific and is determined bythe data type of the data source column.

Note: if the SAS date format and the data source date format match, this option isnot needed.

See: the documentation for your SAS/ACCESS interface.Note:For non-English date types, SAS converts the data to the SAS type of

NUMBER. The SASDATEFMT option does not currently handle these date types. Youcan use a PROC SQL view to convert the data source data to a SAS date format. Thiscan be done as you retrieve the data, or use a format statement in other contexts.

Page 118: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

110

Page 119: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

111

C H A P T E R

9The Pass-Through Facility forPC Files on Microsoft Windows

LIBNAME Statement and Pass-Through Facility on Microsoft Windows 111Syntax for the Pass-Through Facility for PC Files 112

Return Codes 112

Example 112

CONNECT Statement 113

DISCONNECT Statement 117EXECUTE Statement 118

Microsoft Jet and Microsoft Ace Provider Supported Data Types 121

Examples 121

Special Jet and Ace Queries 122

Examples 123

Special Jet Commands 124Examples 124

LIBNAME Statement and Pass-Through Facility on Microsoft Windows

The SQL procedure implements the Structured Query Language (SQL) for SAS. Seethe SQL procedure topic in Base SAS Procedures Guide for information about PROCSQL. You can send data source-specific SQL statements directly to a data source usingan extension to the SQL procedure called the Pass-Through Facility.

This facility uses SAS/ACCESS to connect to a data source and to send statementsdirectly to the data source for execution. This facility is an alternative to theSAS/ACCESS LIBNAME statement. It enables you to use the SQL syntax of your datasource, and it supports any non-ANSI standard SQL that is supported by your datasource.

You can use the Pass-Through Facility for these tasks:

� establish and terminate connections with a data source using the Pass-ThroughFacility CONNECT and DISCONNECT statement.

� send dynamic, non-query, data source-specific SQL statements to a data sourceusing the facility’s EXECUTE statement

� retrieve data directly from a data source using the facility’s CONNECTION TOcomponent in the FROM clause of a PROC SQL SELECT statement.

You can use Pass-Through Facility statements in a PROC SQL query or you canstore them in a PROC SQL view. When you create a PROC SQL view, any argumentsthat you specify in the CONNECT statement are stored with the view. Therefore, whenthe view is used in a SAS program, SAS can establish the appropriate connection to thedata source.

Page 120: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

112 Syntax for the Pass-Through Facility for PC Files � Chapter 9

Syntax for the Pass-Through Facility for PC FilesThis section presents the syntax for the Pass-Through Facility statements and the

CONNECTION TO component. You can use this component with the PROC SQLSELECT statement to query data from a data source.

PROC SQL <options-list>;

CONNECT TO data-source-name <AS alias> <(<connect-statement-arguments><database-connection-arguments>)>;

DISCONNECT FROM data-source-name | alias;

EXECUTE (data-source-specific-SQL-statement) BY data-source-name | alias;

SELECT column-list FROM CONNECTION TO data-source-name | alias(data-source-query)

Return CodesAs you use the PROC SQL statements that are available in the Pass-Through

Facility, any error conditions are written to the SAS log. The Pass-Through Facilitygenerates return codes and messages that are available to you through these SASmacro variables:

SQLXRCcontains the data source return code that identifies the data source error.

SQLXMSGcontains descriptive information about the data source error that is generated bythe data source.

The contents of the SQLXRC and SQLXMSG macro variables are printed in the SASlog using the %PUT macro. They are reset after each Pass-Through Facility statementhas been executed.

ExampleTo connect to an Excel 2007 .xlsx file and query the INVOICE table (range) within

the Excel workbook:

PROC SQL DQUOTE=ANSI;CONNECT TO EXCEL (PATH="c:\sasdemo\sasdemo.xlsx");SELECT * FROM CONNECTION TO EXCEL

(SELECT * FROM INVOICE);DISCONNECT FROM EXCEL;QUIT;

Page 121: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � CONNECT Statement 113

CONNECT Statement

Establishes a connection with the data source.

Valid in: PROC SQL statement

SyntaxCONNECT TO data-source-name <AS alias> <(<connect-statement-arguments>

<database-connection-arguments>)>;

Argumentsdata-source-name

identifies the data source to which you want to connect, such as SAS/ACCESS forMicrosoft Access or EXCEL for Microsoft Excel. You can also specify an optionalalias in the CONNECT statement.

aliasspecifies an optional alias for the connection that has 1 to 32 characters. If youspecify an alias, the keyword AS must appear before the alias. If an alias is notspecified, the data source name is used as the name of the Pass-Throughconnection.

connect-statement-argumentsspecifies arguments that indicate whether you can make multiple connections,shared or unique, or other connections to the database. These CONNECTStatement Arguments are optional.

database-connection-argumentsspecifies the data source-specific arguments that are needed by PROC SQL toconnect to the data source. These arguments are not required, and the defaultbehavior opens a dialog box.

DATABASE Connection ArgumentsThe arguments that are listed below are available with the Pass-Through Facility forPC files.These arguments provide information to the Pass-Through Facility in order to connectto the PC files or to a database.

INIT= "connection-string"specifies an initialization string (that is, a connection string) when connecting to adata source.

PATH="path-for-file"specifies the data source file location for the Microsoft Access database file orMicrosoft Excel workbook file.

PROMPT=YES | NO |REQUIRED | NO PROMPT | PROMPT | UDLdetermines whether you are prompted for connection information to supply to thedata source information.

YES enables you to be prompted with the Data Link Propertieswindow.

Page 122: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

114 CONNECT Statement � Chapter 9

NO does not enable you to be prompted with a window. It requiresyou to specify the physical-filename.

REQUIRED lets you connect without prompting for more information only ifa valid physical filename is specified for a successfulconnection. Otherwise, you are prompted for the connectionoptions with a window that enables you to change the datasource file and other properties.

NOPROMPT disables the prompt of the Data Link Properties window.

PROMPT enables you to be prompted for connection information tosupply the data source information.

UDL enables you to browse and select an existing data link file (.udl).

Note: This statement also applies to the INIT= option andthe UDL= option. �

UDL="path-for-udl-file"specifies the path and filename for a UDL (a Microsoft data link file), as in thisexample:

UDL_FILE="C:\WinNT\profiles\me\desktop\MyDBLink.udl’’;%put %superq(SYSDBMSG);

This option does not support SAS filerefs. The macro variable SYSDBMSG isset on successful completion. For more information, see Microsoft documentationon the data link API.

CONNECT Statement ArgumentsThe arguments that are listed below are available with the Pass-Through FacilityCONNECT statement for PC files. These arguments extend some of the LIBNAMEstatement connection management features to the Pass-Through Facility.

AUTOCOMMIT=YES | NOdetermines whether the SAS/ACCESS engine commits (saves) updates as soon asthe user submits them.

YESspecifies that updates are committed (that is, saved) to table as soon as theyare submitted, and no rollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commitwhen it reaches the end of the file.

Default: YES [different from the LIBNAME option default]

COMMAND_TIMEOUT=number-of-secondsspecifies the number of seconds that pass before a data source command times out.Default: 0 (no time-out)Alias: TIMEOUT

CONNECTION= SHARED | GLOBALspecifies whether multiple CONNECT statements for a data source can use thesame connection. The CONNECTION= option enables you to control the numberof connections, and therefore transactions, that your SAS/ACCESS engine executesand supports for each CONNECT statement.

SHARED

Page 123: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � CONNECT Statement 115

specifies that the CONNECT statement makes one connection to the DBMS.Only Pass-Through statements that use this alias share the connection.

GLOBALspecifies that multiple CONNECT statements can share the same connectionto the DBMS if they use identical values for CONNECTION=,CONNECTION_GROUP=, and any database connection arguments.

Default: SHARED

CONNECTION_GROUP= connection-groupcauses operations against multiple librefs to share a connection to the data source.Also causes operations against multiple the Pass-Through Facility CONNECTStatements to share a connection to the data source.

CURSOR_TYPE=KEYSET_DRIVEN | STATICspecifies the cursor type for read-only cursors and for cursors to be updated.

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set whenthe cursor is opened. However, changes that are made to these rows arereflected as you move the cursor. The OLE DB propertyDBPROP_OTHERUPDATEDELETE=TRUE for keyset cursors and FALSEfor static cursors.

STATICspecifies that the complete result set is built when the cursor is opened.Changes made to the result set are not reflected in the cursor. Static cursorsare read-only.

Default: NoneAlias: CURSOR

DBENCODING=12–byte SAS encoding-valueindicates the encoding used to save data in DBF files. Encoding maps eachcharacter in a character set to a unique numeric representation, which results in atable of code points. A single character can have different numeric representationsin different encodings.

For example, some DBF files were saved with pcoem850 encoding. When youare importing these DBF files in Microsoft Windows, specify:

:DBENCODING=pcoem850.The IMPORT procedure reads and transcodes data from pcoem850 to Microsoft

Windows default WLATIN1.Note: Refer to the SAS NLS User’s Guide for information about transcoding and

valid encoding values.

DBGEN_NAME=DBMS | SASspecifies that the data source columns are renamed, and specifies the format thatthe new names follow.

DBMSspecifies that the data source columns are renamed to valid SAS variablenames. Disallowed characters are converted to underscores. If a column isconverted to a name that already exists, then a sequence number is appendedto the end of the new name.

SASspecifies that data source columns are renamed to the format _COLn, wheren is the column number (starting with zero).

Default: DBMS

Page 124: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

116 CONNECT Statement � Chapter 9

DBMAX_TEXT=nspecifies an integer between 1 and 32,767 that indicates the maximum length for acharacter string. Longer character strings are truncated. This option applies onlywhen you are reading, appending, and updating Microsoft Access or Excelcharacter data from SAS.

Note: Although you can specify a value less than 256, it is not recommended. �Default: 1,024

DEFER=NO | YESenables you to specify when the connection to the data source occurs.

NOspecifies that the connection to the data source occurs when the libref isassigned by a LIBNAME statement.

YESspecifies that the connection to the data source occurs when a table in thedata source is opened.

Default: NO

MSENGINE= ACE|JETdetermines the database engine used for accessing the Microsoft Excel file or theMicrosoft Access database. The Microsoft Jet engine is older and supports formatsup to 2003. The Microsoft Ace engine supports 2007 and older formats.Restriction: It is recommended that you do not use this file option unless you

are trying to create a 95 format file.Default: ACE

READBUFF=number-of-rowsspecifies the number of rows to use when you are reading data from a data source.Setting a higher value for this option reduces I/O and increases performance, butalso increases memory usage. Additionally, if too many rows are read at once,values returned to SAS might be out of date.Default: 1Alias: ROWSET=

ROWSET_SIZE=

STRINGDATES=YES | NOspecifies whether datetime values are read from the data source as characterstrings or as numeric date values. STRINGDATES= is not available as a data setoption.

YESspecifies that SAS/ACCESS reads datetime values as character strings.

NOspecifies that SAS/ACCESS reads datetimes values as numeric date values.

Default: NOAlias: STRDATES

USE_DATETYPE=YES | NOspecifies whether to use DATE. format for date/time columns/fields in the datasource table while importing data from Microsoft Access database or Excelworkbook.

YESspecifies that SAS DATE format is assigned for datetime columns in the datasource table.

Page 125: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � DISCONNECT Statement 117

NOspecifies SAS DATETIME format is assigned for datetime columns in thedata source table.

Default: NO

Alias: STRDATES

DetailsThe CONNECT statement establishes a connection with the data source. You establisha connection to send data source-specific SQL statements to the data source or toretrieve data source data. The connection remains in effect until you issue aDISCONNECT statement or terminate the SQL procedure.

Follow these steps to connect to a data source using the Pass-Through Facility:

1 Initiate a PROC SQL step.

2 Use the Pass-Through Facility’s CONNECT statement, identify the data source(such as Microsoft Access or Excel), and assign an alias if you want.

3 Specify any arguments needed to connect to the database.

4 Specify any attributes for the connection.

The CONNECT statement is optional for some data sources. However, if you do notspecify it, default values for all database connection arguments are used.

Any return code or message that the data source generates is available in the macrovariables SQLXRC and SQLXMSG after the statement executes. See “Return Codes” onpage 112 for more information about these macro variables.

Example

This example uses the CONNECT statement with PATH= option to connect to theMicrosoft Access database file, c:/demo.mdb:

proc sql;connect to access as db (path="c:\demo.mdb");

DISCONNECT Statement

Terminates the connection to the data source.

Valid in: PROC SQL steps

SyntaxDISCONNECT FROM data-source-name | alias

Argumentsdata-source-name

specifies the data source from which you want to disconnect. You can use an aliasin the DISCONNECT statement. The DISCONNECT statement’s data source

Page 126: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

118 EXECUTE Statement � Chapter 9

name or alias must match the name or alias that you specified in the CONNECTstatement.

aliasspecifies an alias that was defined in the CONNECT statement.

DetailsThe DISCONNECT statement ends the connection with the data source. If theDISCONNECT statement is omitted, an implicit DISCONNECT is performed whenPROC SQL terminates. The SQL procedure continues to execute until you submit aQUIT statement, another SAS procedure, or a DATA step.

Any return code or message that is generated by the data source is available in themacro variables SQLXRC and SQLXMSG after the statement executes. See “ReturnCodes” on page 112 for more information about these macro variables.

Example

This example uses the QUIT statement to quit the SQL procedure after theconnection and SQL processing uses the DISCONNECT statement to disconnect theconnection from the database:

disconnect from db;quit;

EXECUTE Statement

Sends data source-specific, non-query SQL statements to the data source.

Valid in: PROC SQL steps

SyntaxEXECUTE (data-source-specific-SQL-statement) BY data-source-name | alias;

Arguments(data-source-specific-SQL-statement)

a dynamic nonquery, data source-specific SQL statement. This argument isrequired and must be enclosed in parentheses. However, the SQL statementcannot contain a semicolon because a semicolon represents the end of a statementin SAS. Depending on your data source, the SQL statement can be case-sensitive.It is passed to the data source exactly as you type it.

Any return code or message that is generated by the data source is available inthe macro variables SQLXRC and SQLXMSG after the statement executes. See“Return Codes” on page 181 for information about these macro variables.

data-source-nameidentifies the data source to which you direct the data source-specific SQLstatement. The keyword BY must appear before the data-source-name argument.You must specify either the data source name or an alias.

Page 127: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � CONNECTION TO Component 119

aliasspecifies an alias that was defined in the CONNECT statement. (You cannot usean alias if the CONNECT statement is omitted.)

DetailsThe EXECUTE statement sends dynamic nonquery, data source-specific SQLstatements to the data source and processes those statements.

The EXECUTE statement cannot be stored as part of a Pass-Through Facility queryin a PROC SQL view.

Useful Statements to Include in EXECUTE StatementsYou can pass these statements to the data source by using the Pass-Through FacilityEXECUTE statement.

CREATEcreates a data source table, view, index, or other data source object, depending onhow the statement is specified.

DELETEdeletes rows from a data source table.

DROPdeletes a data source table, view, or other data source object, depending on howthe statement is specified.

INSERTadds rows to a data source table.

UPDATEmodifies the data in the specified columns of a row in a data source table.

For more information about these and other SQL statements, see the SQLdocumentation for your data source.

ExampleThis example uses the EXECUTE statement to drop a table, create a table, and insert arow of data after the connection:

execute(drop table ‘ My Invoice ‘ ) by db;execute(create table ‘ My Invoice ‘ (‘ Invoice Number ‘ LONG not null,‘ Billed To ‘ VARCHAR(20),‘ Amount ‘ CURRENCY,‘ BILLED ON ‘ DATETIME)) by db;execute(insert into ‘ My Invoice ‘values( 12345, ’John Doe’, 123.45, #11/22/2003#)) by db;

CONNECTION TO Component

Retrieves and uses data source data in a PROC SQL query or view.

Valid in: PROC SQL step SELECT statements

Page 128: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

120 CONNECTION TO Component � Chapter 9

SyntaxCONNECTION TO data-source-name<AS alias>< (database-connection-options)>

Argumentsdata-source-name

identifies the data source (Microsoft Access or Excel) to which you direct the datasource-specific SQL statement.

aliasspecifies an alias, if one was defined in the CONNECT statement.

database-connection-argumentsspecifies the data source-specific arguments that are needed by PROC SQL toconnect to the data source. These arguments are not required and the defaultbehavior opens a dialog box.

DetailsThe CONNECTION TO component specifies the data source connection that you wantto use or that you want to create (if you have omitted the CONNECT statement).CONNECTION TO then enables you to retrieve data source data directly through aPROC SQL query.

You use the CONNECTION TO component in the FROM clause of a PROC SQLSELECT statement:

SELECT column-listFROM CONNECTION TO data source-name (data source-query);

CONNECTION TO can be used in any FROM clause, including those in nestedqueries (that is, in subqueries).

You can store a Pass-Through Facility query in a PROC SQL view and then use thatview in SAS programs. When you create a PROC SQL view, any options that youspecify in the corresponding CONNECT statement are stored too. Thus, when thePROC SQL view is used in a SAS program, SAS can establish the appropriateconnection to the data source.

Because external data sources and SAS have different naming conventions, somedata source column names might be changed when you retrieve data source datathrough the CONNECTION TO component.

Note: You must use back quotes ( ‘ ), not single (’) or double quotes ("), to enclosenames that contain a space. �

Example

This example uses the CONNECTION TO component to query a table or a subtableafter the connection:

select * from connection to db(select * from ‘my invoice‘);select * from connection to db(select ‘Invoice Number‘, Amount from ‘my invoice‘);

Page 129: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � Examples 121

Microsoft Jet and Microsoft Ace Provider Supported Data Types

The following table lists the valid data types that are supported by Jet provider. Youcan use these data types when you use the CREATE statement using the SQLPass-Through Facility to create a table. You can also use the data types when you usedata set option DBTYPE= to change the data type for a loaded column.

Table 9.1 Microsoft Jet Provider Supported Data Types

Data Type Column SizeCreate

Parameters

Prefix/

SuffixComments

BIT 2

BYTE 3

SHORT 5

LONG 10

SINGLE 7

DOUBLE 15

DECIMAL 28 precision,scale See Note 1

COUNTER 10 See Note 2

GUID 16

CURRENCY 19

DATETIME 8 # See Note 3

VARCHAR 255 max length See Note 4

LONGTEXT 536,870,910 See Note 5

VARBINARY 255

BIGBINARY 4000

LONGBINARY 1,073,741,823 See Note 5

1 When you use the data type DECIMAL, you can specify precision and scale.2 When you use the DBTYPE= option, the COUNTER data type is valid only when you set

INSERT_SQL=YES. The COUNTER data type is supported only in the Pass-Through Facilitywhen you create a table.

3 When you use the Pass-Through Facility to set a date/time value, you must add the prefix andsuffix, #. For example, #01/01/2001# and #03/12/1999 12:12:12#.

4 When you use the data types VARCHAR or VARBINARY, you must specify the maximum length.5 All Excel columns can have a null value. Do not specify NOT NULL for a column when you

create an Excel table. However, you can specify NULL or NULL attributes for a field when youcreate an Excel table.

ExamplesThis first example connects to Excel, drops a table named DEMO, and creates a new

table.

proc sql;connect to excel as db (path=’c:\temp\demo.xls’filelock=yes);

Page 130: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

122 Special Jet and Ace Queries � Chapter 9

execute(drop table demo) by db;execute(create table demo(EmpID long, FirstName char(10),

Salary decimal(10,2), hiredate datetime)) by db;execute(insert into demo values(12345678, ’Michael’,

123456.78, #07/01/2001#)) by db;execute(insert into demo values(23456789, ’Howard’, 234567.89,

#04/01/1983#)) by db;execute(insert into demo values(34567890, ’Nancy’, null,

#02/01/1982#)) by db;execute(insert into demo values(34567890, ’Andy’, 456789.01,

null)) by db;select * from connection to db(select * from demo);disconnect from db;quit;

This next example connects to Access, drops a table named DEMO, and creates anew table.

proc sql;connect to Access as db (path=’c:\temp\demo.mdb’);execute(drop table demo) by db;execute(create table demo(EmpID long not null, FirstName char(10) not null,

Salary decimal(10,2), hiredate datetime)) by db;execute(insert into demo values(12345678, ’Michael’,

123456.78, #07/01/2001#)) by db;execute(insert into demo values(23456789, ’Howard’, 234567.89,

#04/01/1983#)) by db;execute(insert into demo values(34567890, ’Nancy’, null,

#02/01/1982#)) by db;execute(insert into demo values(34567890, ’Andy’, 456789.01,

null)) by db;select * from connection to db(select * from demo);disconnect from db;quit;

Special Jet and Ace QueriesSAS/ACCESS Interface to PC Files supports a number of special queries that return

information such as available tables, columns, and procedures.Here is the general format of special queries:

ACE|JET : schema-rowset<"parameter-1",...,"parameter-n">

where

ACE|JETis required to distinguish special queries from regular queries.

schema-rowsetis the specific schema rowset that is being called. The valid schema rowsets arelisted below.

"parameter-n"is a quoted string. Parameters are separated from one another by commas. Allparameters are optional, but the quotation marks must be included. If you specifysome, but not all, parameters within an argument, use commas to indicate theomitted parameters.

Page 131: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � Examples 123

These special queries are supported:

ACE|JET ::CHECK_CONSTRAINTSreturns the check constraints that are defined in the database file.

ACE|JET ::COLUMNS <“table-name”, “column-name”>returns the columns of the tables that are defined in the database file.

ACE|JET ::CONSTRAINT_COLUMN_USAGE <“table-name”, “column-name”>returns the columns that are used by referential constraints, unique constraints,check constraints, and assertions that are defined in the database file.

ACE|JET ::FOREIGN_KEYS <“primary-key-table-name”, “foreign-key-table-name”>returns the foreign key columns that are defined in the database file.

ACE|JET ::INDEXES <“index-name”, “table-name”>returns the indexes that are defined in the database file.

ACE|JET ::KEY_COLUMN_USAGE <“constraint-name”, “table-name”,“column-name”>

returns the key columns that are defined in the database file.

ACE|JET ::PRIMARY_KEYS <“table-name”">returns the primary key columns that are defined in the database file.

ACE|JET ::PROCEDURES <“procedure-name”>returns the procedures that are defined in the database file.

ACE|JET ::PROVIDER_TYPESreturns information about the base data types that are supported by the Jet dataprovider.

ACE|JET ::REFERENTIAL_CONSTRAINTS <“constraint-name”>returns the referential constraints that are defined in the database file.

ACE|JET ::STATISTICS <“table-name”>returns the statistics that are defined in the database file.

ACE|JET ::TABLE_CONSTRAINTS <“constraint-name”, “table-name”,“constraint-type”>

returns the table constraints that are defined in the database file.

ACE|JET ::TABLES <“table-name”, “table-type”>returns the tables that are defined in the database file.

ACE|JET ::VIEWS <“table-name”>returns the viewed tables that are defined in the database file.

ExamplesThis first example retrieves a rowset that displays all tables in the NorthWind

database:

proc sql;* connect to access database;connect to Access as db (path="c:\NorthWind.mdb");* list all tables including system tables and pass-through;select * from connection to db(jet::tables);* list table name and type where table type is TABLE only;select table_name, table_type from connection to db(jet::tables ,"TABLE";disconnect from db;‘

quit;

Page 132: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

124 Special Jet Commands � Chapter 9

In this next example, information is retrieved of all data types that the Ace or Jetprovider for Microsoft Access supports:

proc sql;connect to access (path="c:\NorthWind.mdb");select * from connection to access(jet::provider_types);

quit;

Special Jet CommandsMicrosoft Access and Microsoft Excel engines support several special commands in

the Pass-Through Facility.Here is the general format of special commands:

JET::command

where

JET::is required to distinguish special queries from regular queries.

These special commands are supported:

JET:: COMMITcommits the transaction.

JET::ROLLBACKcauses a rollback in the transaction.

JET::AUTOCOMMITsets the COMMIT mode to AUTO and commits the transaction immediately.

JET::NOAUTOCOMMITsets the COMMIT mode to MANUAL. When the COMMIT mode is set toMANUAL, you must issue a COMMIT or ROLLBACK command to commit orrollback the transaction.

ExamplesThis example specifies the AUTOCOMMIT=NO connection option.

Note: Although these examples state indicate that they are for Microsoft Access, thesyntax is the same for both Microsoft Access and Microsoft Excel. �

proc sql;connect to access( path="d:\dbms\access\test.mdb" autocommit= no );

execute(create table x (c1 int) ) by access;execute(insert into x values( 1 ) ) by access;

/* To commit the table create and insert ; */execute(jet::commit) by access;

execute(insert into x values( 2 ) ) by access;/* To rollback the previous insert ; */

execute(jet::rollback) by access;

Page 133: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The Pass-Through Facility for PC Files on Microsoft Windows � Examples 125

execute(jet::autocommit) by access;/* the insert is automatically committed, you cannot rollback the insert. */

execute(insert into x values( 3 ) ) by access;

/* you should have a table created with 2 rows. */disconnect from access; quit;

Page 134: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

126

Page 135: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

127

C H A P T E R

10File-Specific Reference

Microsoft Excel Workbook Files 127LIBNAME Statements 127

Connection Options 128

LIBNAME Statement or PROC SQL Connect Statement 128

Data Types Conversion 130

Processing Date and Time Values between SAS and Microsoft Excel 131Microsoft Access Files 132

Statements 132

Connection Options 132

Data Types Conversion 133

Processing Date and Time Values between SAS and Microsoft Access 136

Setting Environment Variables: BOOL_VAL 136

Microsoft Excel Workbook Files

LIBNAME StatementsBy default, the SAS LIBNAME statement connects to a Microsoft Excel file in limited

READ/WRITE mode. Although you can read data, delete a table, or create a new table,you cannot update data or append a new data row. To allow data update and append,you can set the LIBNAME option, SCANTEXT=NO.

Because the SAS PROC SQL pass-through connects to a Microsoft Excel file inREAD/WRITE mode, you can read, write, and update data by passing SQL commandstatements.

CAUTION:Due to the use of the Microsoft Jet Excel engine and the Microsoft Ace Excel engine, theSAS engines for Excel have limited update and delete capability. There might be otherunsolved issues. You should therefore avoid using the update and delete features. Back upyour Excel files before you try using any update functions. �

CAUTION:Although SAS allows you to connect to an Excel file while the application is opening it, anyupdates to the Excel file can cause the SAS Excel engine to malfunction. It isrecommended that you close the application that is using the Excel file, disconnect, andthen reconnect the file in SAS. You can set the LIBNAME option, FILELOCK=YES, to makesure that Excel or other applications has not opened the connected Excel file. �

Page 136: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

128 Connection Options � Chapter 10

Connection Options

LIBNAME Statement or PROC SQL Connect StatementYou can use this connection option in the LIBNAME statement or in the PROC SQL

CONNECT statement.

HEADER=YES|NOwhen SAS reads Microsoft Excel data, it determines whether the first row of datain a Microsoft Excel range (or spreadsheet) are column names.

YES specifies to use the first row of data in an Excel range (orspreadsheet) as column names when SAS is reading data froman Excel file.

NO specifies not to use the first row of data as column names in anExcel range (or spreadsheet) when SAS is reading data from anExcel file. SAS generates and uses the variable names F1, F2,F3, and so on.

Alias: HDR|GETNAMES

Default: YES

Note: This connection option is only for reading Microsoft Excel spreadsheets.This option is ignored when you are writing data to an Excel spreadsheet.

MIXED=YES|NOspecifies whether to convert numeric data values into character data values for acolumn that contains mixed data types. This option is valid only when you import(read) data from Excel. The Microsoft Ace and Jet Excel engines handle this option.

YESassigns a SAS character type for the column and converts all numeric datavalues to character data values when mixed data types are found. When youspecify MIXED=YES, the connection is set in import mode and no updatesare allowed.

CAUTION:Due to a limitation in the Microsoft Ace and Microsoft Jet engines, MIXED=YEScould result in improper text variable lengths. �

NOassigns numeric or character type for the column, depending on the majorityof the type data that is found. Both numeric data in a character column andcharacter data in a numeric column are imported as missing values.

Default: NO

Restriction: DBMS= only

Restriction: This option is available only for Windows reading Excel data intoSAS. You cannot use this option for delimited files.

Restriction: Registry settings might affect the behavior of the MIXED= option.

For the Microsoft Jet engine, these settings are located in the[\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel]key of the Windows registry.

For the Microsoft Ace engine, these settings are located in the[\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\AccesConnectivity Engine] key of the Windows registry.

Page 137: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Connection Options 129

Table 10.1 Registry Settings for the MIXED Option

TypeGuessRows an integer type with a default value of 8. You can use the number ofrows in the worksheet range in scans to determine column types. Ifyou set this type to 0, all rows in the range are checked. Microsoftstates that the valid range of TypeGuessRows is 0–16. However, youcould set as high as 16384 and it would still operate correctly.

CAUTION:Changing the TypeGuessRows value cause a scan to fail ifyou set it the value higher than 16384. Changes also affectany software that uses the Microsoft Jet provider to accessExcel file data, including accessing Excel data in aMicrosoft Access database. The TypeGuessRows value isregistered with and controlled by Microsoft. It is thereforerecommended that you set the value to 0. �

ImportMixedTypes a string type with a default value of Text. If a column contains morethan one type of data while scanning TypeGuessRows rows, the typeof the column is determined to be Text if the value of the setting isText. If the value of the setting is Majority, the most common type inthe column determines the column type.

For the MIXED=YES option to work correctly, you should you changeTypeGuessingRows to 0 in the Microsoft Windows registry so that allrows in the specified range are scanned. As a result, when you useMIXED=YES, the Jet provider always assigns character type forcolumns with data of mixed data types and converts numeric data tocharacter data.

TypeGuessRows an integer type with a default value of 8. The number of rowsin the worksheet range is used to scan and determine columntypes. If set to 0, then all rows in the range are checked.Microsoft states that the valid range of TypeGuessRows is 0 to16. However, it can be set as high as 16,384 and still operatecorrectly.

ImportMixedTypes a string type with a default value of Text. If a column containsmore than one type of data (during the scan of TypeGuessRowsrows), the type of the column is determined to be Text if thevalue of the setting is Text. If the value of the setting isMajority, then the most common type in the column determinesthe column type.

CAUTION:These settings are registered by the Microsoft Jet engine. Changing settings such asTypeGuessRows for Microsoft Jet engine in the Windows registry affects all softwarethat uses Microsoft Jet engine to import data. This includes Microsoft Officeproducts, as well as other database products and application software. �

Note: For the MIXED=YES option to work correctly, it is strongly recommendedthat you change TypeGuessingRows to 0 in the Windows registry so that allrows in the specified range are scanned. As a result, when you useMIXED=YES, the Jet provider always assigns character type for columns withmixed data types and converts numeric data to character data.

VERSION=’2007’ |’2003’|’2002’|’2000’|’97’|’95’|’5’specifies the version of the file that you want to create if the file does not exist.Valid values are 2003, 2002, 2000, 97, 95, and 5. The default value is 97.

Page 138: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

130 Data Types Conversion � Chapter 10

Alias: VERNote: You do not need to specify this option if you do not know the version of

your Microsoft Excel file. However, if you want to create a new Microsoft Excelfile, you can use this option to specify the version that you create. There is noneed to specify the VERSION= value if you want to create a 2007 Excel .xlsb or.xlsx file. The file extension tells SAS the VERSION= value.

Note: Versions 2003, 2002, 2000, and 97 are treated as the same format.Versions 95 and 5 share the same format.

Data Types ConversionThis table shows the default SAS variable formats that SAS/ACCESS assigns to

Excel data types. These data types are assigned when SAS reads data from MicrosoftExcel spreadsheets using the LIBNAME engine.

Table 10.2 Default SAS Formats Assigned for Excel Formats

Excel Column

Format

SAS Variable

Format

SAS Variable

Type

Text $w. Character

General Numeric

Number Numeric

Scientific Numeric

Percentage See Note 3 Numeric

Fraction See Note 3 Numeric

Currency DOLLAR21.2 Numeric

Accounting DOLLAR21.2 Numeric

Date Date9. See Note 12 Numeric

Datetime Date9.12 Numeric

Time Date9.12 Numeric

1 The default format is DATE9. You can use USEDATE=NO to change format from DATE. toDATETIME. You can also use the SASDATEFMT= option to change the format of other SASdate or date/time formats.

2 Note that the SAS date time value uses 01Jan1960 as a cutoff line, while the Jet provider date/time value uses 30Dec1899 as a cutoff line for internal values.

3 To access Fraction or Percent format data in your Excel file, you can use the FORMAT statementto assign the FRACT. or PERCENT. format in your DATA step code.

The following table shows the default Excel data types that SAS/ACCESS assigns toSAS variable formats. These data types are assigned when SAS writes data to an Excelfile using the LIBNAME engine. You can override these default conversions by using“DBTYPE” on page 103 during output processing.

Page 139: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Processing Date and Time Values between SAS and Microsoft Excel 131

Table 10.3 Default Excel Formats Assigned for SAS Variable Formats

SAS Variable

Format

XLS Column

Data Type

$BINARYw. Text

$CHARw. Text

$HEX w. Text

$w. Text

w.d Number

BESTw. Number

BINARYw. Number

COMMA w.d Number

COMMAXw.d Number

Ew. Number

FRACTw. Number

HEXw. Number

NEGPARENw.d Number

PERCENTw.d Number

DOLLARw.d Currency

DOLLARXw.d Currency

DATEw. Date/Time

DATETIMEw.d Date/Time

DDMMYYw. Date/Time

HHMMw.d Date/Time

JULDAYw. Date/Time

JULIANw. Date/Time

MMDDYYw. Date/Time

MMYYw.d Date/Time

MONTHw. Date/Time

MOYYw. Date/Time

WEEKDATEw. Date/Time

WEEKDATXw. Date/Time

WEEKDAYw. Date/Time

WORDDATEw. Date/Time

WORDDATXw. Date/Time

Processing Date and Time Values between SAS and Microsoft ExcelTo import date/time values from a Microsoft Excel file, the SAS LIBNAME engine

reads date and time values using the DATE format by default. However, you can set

Page 140: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

132 Microsoft Access Files � Chapter 10

the LIBNAME option, USEDATE=NO, or the LIBNAME statement, USEDATE=NO.Using the IMPORT procedure, you can have date and time values read in using theDATETIME format.

To export SAS data values with DATE, TIME, or DATETIME format to a MicrosoftExcel file, SAS values are written into the Excel file using the DATE format. When yousee values with the date 1/0/1900 in Microsoft Excel, you need to format them using theTIME format before you can see the correct time values.

TIME_VAL: By default, the SAS/ACCESS LIBNAME engine loads the SAS timevalue in the ACCESS database. The time value is set to less than or equal to 24 hours.You can set the time environment variable, with the following code:

options SET=TIME_VAL SAS:

To load SAS time values to the ACCESS database with the SAS date and time base of01Jan1960:00:00:00, allows the time value to be reserved for longer than one day. Whenyou import data with SCANTIME=YES, SAS scans date and time values in the columnand assigns the TIME. format if all the values in the column are in the year 1960. Ifthis is not the case, SAS assigns the DATETIME. format for the column. You can resetthe TIME_VAL back to the default value with the following code:

options SET=TIME_VAL_ONEDAY;

Microsoft Access Files

StatementsThe SAS/ACCESS LIBNAME statement connects to a Microsoft Access database

MDB file in READ/WRITE mode by default. The SAS CONNECT statement in PROCSQL also connects in READ/WRITE mode by default. You can set the LIBNAME optionACCESS=READONLY to connect to the file in READONLY mode.

The SAS engine for the Microsoft Access database uses the Microsoft Jet Provider toconnect to Microsoft Access data in the MDB file. A connection requires an existingMDB file. The engine knows the version of the MDB file that the Microsoft Accessdatabase saves.

The engine supports some special queries, which return information such as availabletables, primary keys, foreign keys, and indexes. For more information, see Chapter 9,“The Pass-Through Facility for PC Files on Microsoft Windows,” on page 111.

Connection OptionsThese connection options can be used in the LIBNAME statement or in the PROC

SQL statement.

Note: You can use USER , PASSWORD , DBPASSWORD , and DBSYSFILE toaccess your .mdb files, but it does not change your current security settings for thosefiles. �

DBPASSWORD="database-file-password"enables you to access your file if you have database-level security set in your .mdbfile. A database password is case sensitive and can be defined in addition touser-level security. Do not include ampersands, quotation marks, or invisiblecharacters in your password.

Page 141: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Data Types Conversion 133

Alias: DBPWD|DBPW

DBSYSFILE="workgroup-information-file"contains information about the users in a workgroup based on information thatyou define for your Microsoft Access database. Any user and group accounts orpasswords that you create are saved in the workgroup information file.Alias: DBSYS|WGDB

PASSWORD="user-password"specifies a password for the user account. A password can be 1 to 14 characterslong and can include any characters except ASCII character 0 (null). Passwordsare case sensitive. Do not include ampersands, quotation marks, or invisiblecharacters in your password.

Note: If you have user-level security set in your .mdb file, you need to use thisoption and the USER option to be able to access your file. �Alias: PWD|PW

USER= "user-ID"specifies a user account name. User names can be 1 to 20 characters long and caninclude alphabetic characters, accented characters, numbers, and spaces.Alias: UID|USERIDNote: If you have user-level security set in your .mdb file, you need to use this

option and the PASSWORD option to be able to access your file.

Data Types ConversionThe following table shows the default SAS variable formats that SAS/ACCESS

assigns to .mdb data types. These formats are assigned when SAS reads data fromMicrosoft Access files using the LIBNAME engine.

Table 10.4 Default SAS Formats Assigned for MDB Data Types

MDB Field Data Type SAS Variable Format SAS Variable Type

Yes|No 2. Numeric

Number (FieldSize=Byte) 4. Numeric

Number(FieldSize=Integer)

6. Numeric

Number (FieldSize=LongInteger)

11. Numeric

Number (FieldSize=Single) Numeric

Number(FieldSize=Double)

Numeric

AutoNumber(FieldSize=Long Integer)

11. Numeric

AutoNumber(FieldSize=Replication ID)

$38. Character

CURRENCY DOLLAR21.2 Numeric

Date/Time DATETIME.

12

Numeric

Page 142: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

134 Data Types Conversion � Chapter 10

MDB Field Data Type SAS Variable Format SAS Variable Type

Text $w. 3 Character

Memo $w. 4 Character

OLE Object $w. 4 Character

Hyperlink $w. 4 Character

1 The default format is DATETIME. You can use USEDATE=YES to change format fromDATETIME. to DATE. You can also use the SASDATEFMT option to change the format toother date or date and time formats.

2 The SAS date/time value uses 01Jan1960 as the cutoff date. The Jet provider date/ time valueuses 30Dec1899 as the cutoff date.

3 The width of $w. is equal to the field size of the column defined in your Microsoft Access table.4 When SCANMEMO=YES (the default is value NO), the width value of $w. is determined by the

longest string of data that is scanned in the field, or by the value specified in the DBMAX_TEXT=option, whichever is less. Otherwise, when the option SCAN_TEXT=NO, the width value of $w.is equal to the value specified in DBMAX_TEXT= option.

The following table shows the default .mdb data types that SAS/ACCESS assigns toSAS variable formats. These data types are assigned when you write SAS data to an.mdb file using the LIBNAME engine. You can override these default conversions byusing the DBTYPE data set option during processing.

Table 10.5 Default DB Data Types Assigned for SAS Variable Formats

SAS Variable Format MDB Data Type

$BINARYw. Text (VarChar) or Memo (LongText) 1

$CHARw. Text (VarChar) or Memo (LongText)1

HEX w. Text (VarChar) or Memo (LongText) 1

$w. Text (VarChar) or Memo (LongText)1

w.d Number 2

BESTw. Number 2

BINARYw. Number 2

COMMA w.d Number 2

COMMAXw.d Number 2

Ew. Number 2

FRACTw. Number 2

HEXw. Number 2

NEGPARENw.d Number 2

PERCENTw.d Number 2

DOLLARw.d Currency

DOLLARXw.d Currency

DATEw. Date/Time

DATETIMEw.d Date/Time

DDMMYYw. Date/Time

Page 143: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Data Types Conversion 135

SAS Variable Format MDB Data Type

HHMMw.d Date/Time

JULDAYw. Date/Time

JULIANw. Date/Time

MMDDYYw. Date/Time

MMYYw.d Date/Time

MONTHw. Date/Time

MOYYw. Date/Time

WEEKDATEw. Date/Time

WEEKDATXw. Date/Time

WEEKDAYw. Date/Time

WORDDATEw. Date/Time

WORDDATXw. Date/Time

1 If the character format length is greater than 255 characters, the loaded format is Memo.Otherwise, the loaded format is Text.

2 For Microsoft Access 2000, 2002, and 2003, a SAS numeric data type with no format specified isconverted to a number data type with a double field size. If the format is specified as w. in SAS,the loaded data type in Microsoft Access is a number data type with a long integer field size.If the format is specified as w.d in SAS, the loaded data type in Microsoft Access is a numberdata type with a decimal field size. For Microsoft Access 97, if the format is specified as w. inSAS, the loaded data type in Microsoft Access is a number data type with a long integer fieldsize. Otherwise, the SAS numeric data type is converted to a number data type with a doublefield size. However, you can set the SAS environment variable, LOAD_DBL=YES, to force aSAS numeric data type to be loaded into a numeric data type with a Double field size.

Example:

data test;format j 5. k 6.2;i=123.45; j=12345; k=123.45;run;

/* The following PROC loads the Test1 table, which containsColumn i with a Double field size,Column j with a Long Integer field size,and Column k with a Decimal field size. */PROC EXPORT DATA=test

OUTTABLE= "Test1"DBMS=ACCESS REPLACE;

DATABASE=’c:\temp\test.mdb’;RUN;

/* The following PROC loads the Test2 table, which containsColumns i, j, and k, all of which have a Double field size. */

options set=load_dbl yes;PROC EXPORT DATA=test

OUTTABLE= "Test2"DBMS=ACCESS REPLACE;

DATABASE=’c:\temp\test.mdb’;RUN;

Page 144: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

136 Processing Date and Time Values between SAS and Microsoft Access � Chapter 10

Processing Date and Time Values between SAS and Microsoft AccessTo import date and time values from a Microsoft Access database, the SAS/ACCESS

LIBNAME engine reads in the date and time values using the DATETIME format bydefault. However, you can set the LIBNAME option, USEDATE=YES, or the LIBNAMEstatement, USEDATE=YES. Using the IMPORT procedure, you can have date and timevalues read in using the DATE format.

To export SAS data values with DATE, TIME, or DATETIME format to a MicrosoftAccess database, SAS values are written into the Microsoft Access database using thedate and time data type. However, Microsoft Access can identify and display the valuesin the correct DATE, TIME, or DATETIME format.

Setting Environment Variables: BOOL_VALBy default, the SAS/ACCESS LIBNAME engine imports YES (TRUE) into SAS as the

numeric value 1. You can set the environment variable with the following statement:

/* To have the YES value imported into SAS as numeric value-1 */options SET=BOOL_VAL ASIS;

/* Reset to the default value */options SET=BOOL_VAL SAS;

By default, the SAS/ACCESS LIBNAME engine loads SAS time values into MicrosoftAccess databases with a time value less than or equal to 24 hours. You can set theenvironment variable with the following statement:

/* To have SAS time values exported to Microsoft Accessdatabase with SAS date/time base, 01Jan1960. */options SET=TIME_VAL SAS:

When importing data with the SCANTIME=YES option, SAS scans date/time valuesin the columns and assigns the TIME. format if all the values are in the year 1960.Otherwise SAS assigns the DATETIME. format to the columns.

/* Reset to default value */options SET=TIME_VAL ONEDAY;

By default, SAS loads the numeric value of format w.d with a decimal field size intoAccess database files, Version 2000 or later. The decimal type field takes more spacethan a double type field. To manage your storage space, you can set the environmentvariable with the following statement:

/* To have SAS numeric values loaded into an Access databasewith a double field type, to save storage space. */options SET=LOAD_DBL YES;

/* To reset to the default behavior */options SET=LOAD_DBL NO;

Page 145: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

137

P A R T4

LIBNAME Statement and Pass-ThroughFacility on Linux, UNIX, and 64-Bit MicrosoftWindows

Chapter 11. . . . . . . . .PC Files Server Administration 139

Chapter 12. . . . . . . . .LIBNAME Statement: PC Files on Linux, UNIX, and 64-BitMicrosoft Windows 149

Chapter 13. . . . . . . . .Pass-Through Facility: PC Files on Linux, UNIX, and 64-BitMicrosoft Windows 179

Page 146: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

138

Page 147: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

139

C H A P T E R

11PC Files Server Administration

Overview 139Server Modes 140

PC Files Server Installation 140

Windows Service 140

Service Options 141

Desktop Application 141Desktop Application Window 141

Window Items 142

Configuring PC Files Server 143

Port Number or Service Name 143

Maximum Connections 144

Data Encryption 144Authentication 144

Access to PC Files Server 144

Access to Individual Files 145

System Administrator Tasks 145

Windows Vista Security Model 145PC Files Server Autostart 145

Local Security Policy Configuration 146

Configure User Accounts 146

Constraints 147

Shared Information 147

OverviewPC Files Server is an application that receives to client requests. It runs on either

Microsoft 32-bit Windows, or Microsoft 64-bit Windows with Windows on Windows64-bit subsystem support (WOW64, an x86 emulator).

To access PC data, SAS/ACCESS Interface to PC Files must be installed on theclient. The server must be installed and running on the Windows PC where the PCdata resides.

Page 148: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

140 Server Modes � Chapter 11

Figure 11.1 PC Files Server

Server ModesStarting with SAS/ACCESS 9.2, the server can run in two modes: Server Mode as a

desktop application (available before 9.2), and Service Mode as a Windows service. Onlyone instance of the server can be running on a single PC at any given time.

PC Files Server Installation

By default, there is an installation option that enables PC Files Server to runautomatically in service mode. When this option is set during installation, PC FilesServer automatically starts as a service. If the option is cleared during installation, PCFiles Server does not start automatically, and the server has to be started manually.

Windows ServiceThe server can be manually set to run as a Windows service.To run as a Windows service select Start � Control Panel � Administrative Tools

� Services

Page 149: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

PC Files Server Administration � Desktop Application Window 141

Locate SAS PC Files Server in the Name column. Select Properties.

Service OptionsService name: SAS PC Files Server.Display name: SAS PC Files Server (default).Description: Enables SAS/ACCESS Interface to PC files, such as Excel and MS

Access.Path to executable: path to server install files. Example: "C:\Program

Files\SAS\PCFilesServer\9.2\pcfservice.exe" -name "SAS PC Files Server"Start up type: Start up options.� Automatic: start PC Files Server as a Windows service automatically when the

system starts� Manual: manually start PC Files Server as needed� Disable: prevents the system, a user, or any dependent device from starting PC

Files Server

Service status displays the current status of the Windows service� Stop: the server� Start: the Windows service starts PC Files Server

Desktop ApplicationTo run server mode, stop the service mode. Start � Control Panel � Administrative

Tools � Services. Locate, then open the Properties forSAS PC Files Server. ClickStop, to stop the service.

Desktop Application WindowTo start PC Files Server as a desktop application, select Start � SAS � PC Files

Server. The PC Files Server desktop application window displays.

Page 150: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

142 Window Items � Chapter 11

Figure 11.2 PC Files Server

Window Items� Server Name: names Windows PC where PC Files Server is running.� Service|Port: a communications end point at which a server listens for request

for service from the client application

Page 151: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

PC Files Server Administration � Port Number or Service Name 143

� Default: 8621.

� Max Connections: the maximum number of concurrent connections that thisserver supports.

� Data Encryption: encrypts data during transfer.

� Authentication Required: requires users to provide credentials beforeconnecting to PC Files Server. These can be in the form of a User ID andpassword, or Integrated Windows Authentication (SSPI).

� Allow Integrated Windows Authentication (SSPI): Windows 64–bit userscan process credentials between Windows PCs without having to explicitly give aUser ID and password.

Note: Note: This option is available only when Authentication Required: isselected. �

� Change Options: displays a dialog box that enables you to change the connectionoptions. A note states that the PC Files Server must be restarted in order for thechanges to take effect.

� Restart Server: restarts the server including all setting changes� Shutdown Server: stops the server and closes the application window� Host Name: lists host names of active server connections� DSN|File Access: displays file access requests of active server connections.

� User ID: displays the User ID of active server connections� Current Client Connections: the total number of active connections

Note: When a single user opens multiple connections, this displays the mostcurrent information �

� Peak Client Connections: the greatest number of active connections duringthe current server session

Configuring PC Files ServerBoth server mode and service mode store the server configuration settings in the

Windows registry. Changing the settings while in server mode affects the serverrunning service mode. If you run the server in service mode a separate user interface isnot provided. The default configuration should be sufficient for most installations. Tochange the configuration options run the server in server mode.

1 Stop the Windows service that runs server, see “Windows Service” on page 140.2 Start the server desktop application, see “Desktop Application” on page 141.

3 Change the options that you want.4 Stop PC Files Server desktop application.5 Start the Windows service that runs PC Files Server.

Port Number or Service NameThe PC Files ServerPort Number must be unique on a given PC. You cannot run

multiple servers of any kind that use the same port number on a single PC. You can,however, use the same server Port Number on different PCs.

Page 152: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

144 Maximum Connections � Chapter 11

The Port Number for PC Files Server defaults to 8621. 8621 is also the default portnumber that the LIBNAME statement uses for connections to PC files. If you changethe port number on the server, users accessing that server must add the PORT=numberoption to their LIBNAME statements.

The Port Number or Service Name is saved in the Windows registry and it is usedeach time server PC Files Server is run.

Maximum ConnectionsMax Connections specifies the number of concurrent connections that the server can

support. Configure the number of connections based on the load that you expect fromyour SAS clients.

Each command that uses the server uses one connection. There can be multipleusers from different SAS sessions accessing the server concurrently. Consider all theconnections when setting the Max Connections value. The number of MaxConnections is saved in the Windows registry, and it is used each time the PC FilesServer is run.

Data EncryptionTo enable data encryption between SAS/ACCESS Interface to PC Files on the client

and PC Files Server, select the Data Encryption check box.The state of the Data Encryption is saved in the Windows registry, and it is used

each time PC Files Server is run.

Authentication

Authentication enables PC Files Server system administrators to secure the serverand enforce security. You can configure PC Files Server so that a User ID and apassword are required to connect to a server and access files. You can also configure PCFiles Server on specific hosts to require a User ID and password.

All the commands that allow server access support user authentication. Thecredentials supplied to PC Files Server are verified against the Windows login database.These are the same credentials that are required to interactively logon to a PC.

SERVERUSER=, SERVERPASS=, and SSPI= options have been added to theLIBNAME statement, and the IMPORT and EXPORT procedures. Use these optionswith PC Files engine to supply credentials to the PC Files Server.

� See the “LIBNAME Statement:PC Files on Microsoft Windows” on page 79 and .

� See the Chapter 6, “File Format-Specific Reference for the IMPORT and EXPORTProcedures,” on page 25.

Note: If the client PC is on a domain, the credentials are compared to the domaindata, instead of the local data. �

Access to PC Files ServerAccess to the server is granted only if the credentials supplied are valid on the target

PC. When connecting from a UNIX workstation to the PC, the UNIX credentials (UserID and password) can be different from the credentials used to access the PC files.

Page 153: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

PC Files Server Administration � PC Files Server Autostart 145

Access to Individual FilesAfter the server is secured, the server administrators can enable security settings at

the file level. When a server connection is established, access to individual files issecured using the credentials specified by the user. File access is administered as if theclient is logged on to that PC.

System Administrator TasksTo enforce a security policy, the system administrator should ensure that the� Local security policy is configured, see “Local Security Policy Configuration” on

page 146.� Server authentication is configured, with PC Files Server desktop application.

Start � All Programs � SAS � PC Files Server. Select AuthenticationRequired. See “Service Options” on page 141.

� 64–bit PC Connections: Allow Integrated Windows Authentication (SSPI).This option is for clients on PCs running 64-bit Windows connecting to PC FilesServer. Credentials are exchanged between the server and the client. The clientdoes not have to explicitly set credentials. See “Service Options” on page 141.

� Access to the server requires a User ID and password using the SERVERUSER=and SERVERPASS= options. For a 64–Bit Windows environment, you can also usethe SSPI= option.

Windows Vista Security ModelThe enhanced Windows Vista Security Model is designed to make it more difficult for

viruses, and other software that interferes with computer functions, to installthemselves on the PC. When logged in as “Administrator” or part of the “AdministratorsGroup”, certain privileges are temporarily not available to the operating system. Theprivileges are returned when needed and confirmed by “Windows needs your permissionto continue” dialog box. This guarantees the user is aware of potential security risks.

When starting the server on Windows Vista, manual intervention is required toenable permissions. The confirmation is not required when running the server as aWindows service or if the Windows Vista security features have been disabled.

PC Files Server AutostartSAS running on 64-bit Windows on a local host traditionally cannot access PC files

directly on the local host. The required 32–bit ODBC drivers are incompatible with SASon 64-bit Windows PC Files Server.

The autostart PC Files Server feature facilitates access to PC files on local PCsrunning SAS on 64-bit Windows. PC Files Server autostart features:

� Starts PC Files Server in the background as needed and stops the server whenfinished.

� Does not require the server setup or options.� Communicates with the SAS client using a named pipe.

� Does not transfer data over the network. This eliminates the need for dataencryption.

Page 154: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

146 Local Security Policy Configuration � Chapter 11

� Runs independent of network settings and any other instances of PC Files Server.� Always runs with the credentials of the SAS client. This eliminates the need for

authentication.� Autostart instances of PC Files Server are independent and using their own

communication mechanisms. This eliminates the possibility of an autostartedserver interfering with other servers.

To use this feature you must:� Run SAS on a PC running 64-bit Windows.� Install PC Files Server server on the same PC.� Use a PC Files Server related engine to access either local files or files that are

accessible with the \\host-name\folder\filename specification.� Omit the SERVER= and PORT= options.� Do not use SERVERUSER=, SERVERPASS=, or SSPI= options.

In the following LIBNAME statement and IMPORT procedure, autostart is triggeredby the ’missing’ SERVER= and PORT= options.

LIBNAME db pcfiles path=’C:\myfile.mdb’;

PROC IMPORT out=work.test datafile=’C:\myfile.mdb’ dbms=accesscs replace;run;

Local Security Policy ConfigurationFor server user authentication to work, the server must be able to create

user–specific subprocesses with the credentials specified. Windows allows this only ifcertain Windows Security settings are set on the PC running the server.

When running the server exclusively as a Windows service, use the default accountof SYSTEM. Changes might not be needed if the SYSTEM account has all the requiredprivileges set.

Configure User AccountsThe user account running the server must be in the Administrators group. To access

the Administrators Group;1 Select Start � Settings � Control Panel � User Accounts � Users.2 Select the user account running the server. If you are on a domain, it appears as

the domain name in the Domain column. Select the domain-level user account.3 Properties � Group Membership � Other.4 Open the pull-down list and select Administrators.5 Click OK to close the Group Membership tab.6 If prompted to logout, click Cancel.7 Enable the following User Rights for the Administrators Group:

a Act as part of the operating system.b Adjust memory quotas for a process.c Replace a process level token.To verify or update these rights, select Start � Control Panel �

Administrative Tools � Local Security Policy � User Rights Assignment.

Page 155: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

PC Files Server Administration � Shared Information 147

8 In the Security Settings pane, open Local Policies � User Rights Assignment.9 In the Policy column, open the user right to be changed and add Administrators.

Ensure there is an "s" at the end of Administrators. Administrator (singular) isa specific user account.

10 Repeat the sequence for each of the user rights.11 Verify that the Administrators group has been added to each of the three user

rights, as indicated previously.12 Add the Authenticated Users group to the Log on as batch job user right.13 Logout and log back in for the changes to take effect.

Constraints

� The server can run in server mode or service mode. However, only one instance ofthe server can be running on a single PC, at any given time.

� Service names and port numbers must be unique on a given PC.� To modify the settings:

1 Stop the server.2 Make necessary changes.3 Restart the server.

� Each time you stop or restart the server, all users’ sessions are closed. Closingthese sessions might result in loss of data.

� Although you can change server configuration only in server mode, the updatedvalues also apply when running in service mode.

Shared InformationAfter the server is started and running, the clients need the following information to

access the server:� If the clients are accessing a server that requires authentication, specify the

SERVERUSER= and SERVERPASS= options. For a 64–Bit Windows environment,you can also specify the SSPI= option.

� Server name (host name, or IP address of the PC running the server).� Port number or service name. If you do not use the default value, you must specify

the port number in the LIBNAME statement on the client PC.

PORT=value

� Path to any files, or ODBC data sources to which they have access that is relativeto the files system on the server PC, such as "C:\Excel files\mysheet.xls". Enclosethe path in double–quotes.

Page 156: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

148

Page 157: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

149

C H A P T E R

12LIBNAME Statement: PC Fileson Linux, UNIX, and 64-BitMicrosoft Windows

LIBNAME Statement for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows 149Sorting PC Files Data 150

Using SAS Functions with PC Files Data 150

Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows 150

SAS LIBNAME Options for PC Files on Linux and UNIX 156

Data Set Options for PC Files on Linux and UNIX, and 64-Bit Windows 162AUTOCOMMIT= Data Set Option 162

COMMAND_TIMEOUT= Data Set Option 163

CURSOR_TYPE= Data Set Option 163

DBCOMMIT= Data Set Option 164

DBCONDITION= Data Set Option 165

DBCREATE_TABLE_OPTS= Data Set Option 165DBFORCE= Data Set Option 166

DBGEN_NAME= Data Set Option 167

DBKEY= Data Set Option 168

DBLABEL= Data Set Option 168

DBMAX_TEXT= Data Set Option 169DBNULL= Data Set Option 170

DBNULLKEYS= Data Set Option 171

DBSASTYPE= Data Set Option 171

DBTYPE= Data Set Option 172

ERRLIMIT= Data Set Option 173INSERT_SQL= Data Set Option 174

INSERTBUFF= Data Set Option 174

NULLCHAR= Data Set Option 175

NULLCHARVAL= Data Set Option 176

READBUFF= Data Set Option 176

SASDATEFMT= Data Set Option 177

LIBNAME Statement for PC Files on Linux, UNIX, and 64-Bit MicrosoftWindows

For PC files, the SAS/ACCESS LIBNAME statement extends the SAS globalLIBNAME statement to support assigning a libref to Microsoft Excel, Microsoft Access,and ODBC data sources. This enables you to reference spreadsheets, databases, andODBC sources directly in a DATA step or SAS procedure, and to read from and write toan Access, Excel, or ODBC table as if it were a SAS data set. This section specifies the“Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows” on page 150 forthis statement and provides “Examples” on page 154.

Page 158: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

150 Sorting PC Files Data � Chapter 12

Sorting PC Files DataBecause librefs that refer to PC data refer to database and workbook objects such as

tables, they are stored in a format that differs from that of normal SAS data sets. Thisis important to remember when you access and work with PC files data.

For example, you can sort the observations in a normal SAS data set and store theoutput to another data set. However, in an Access database, sorting data has no effecton how it is stored. Because your data might not be sorted in the external file, youmust sort the data at the time of query.

Furthermore, when you sort PC files data, the results might vary depending onwhether the external spreadsheet or database places data with NULL values (which aretranslated in SAS to missing values) at the beginning or the end of the result set.

Using SAS Functions with PC Files DataWhen you use librefs that refer to PC files data with SAS functions, some functions

might return a value different from what is returned when you use the functions withnormal SAS data sets.

For example, the PATHNAME= function normally returns the pathname for theassigned libref. However, when the libref refers to PC files data, the function mightreturn an Excel filename assigned for the libref.

Usage of some functions might also vary. For example, the LIBNAME function canaccept an optional SAS data-library argument. When you use the LIBNAME functionto assign or deassign a libref that refers to PC files data, however, you omit thisargument. For full details about how to use SAS functions, see the SAS LanguageReference: Dictionary.

Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows

Associates a SAS libref with a workbook, database, or ODBC data source.

Valid in: Anywhere

Syntaxu LIBNAME libref pcfiles

<connection-options><LIBNAME-options>;

v LIBNAME libref CLEAR|_ALL_ CLEAR;

w LIBNAME libref LIST| _ALL_ LIST;

Arguments

_ALL_specifies to the CLEAR= and LIST= arguments to apply the argument to all librefs.

CLEAR

Page 159: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Syntax for PC Files on Linux, UNIX, and 64-Bit

Microsoft Windows 151

clears one or all librefs.Specify libref to clear single libref. Specify _ALL_ to clear all librefs.

“PC Files Server Connection Options” on page 151provide connection information to SAS/ACCESS to connect to your PC files. If theconnection options contain characters that are not allowed in SAS names, enclose thevalues of the arguments in quotation marks. In some instances, if you specify theappropriate system options or environment variables for your data source, you canomit the connection options.

LIBNAME optionsdefine how SAS processes data source objects. For example, some LIBNAME optionscan improve performance. For many tasks, you do not need to specify any of theseadvanced options.

See “LIBNAME Options” on page 85 for detailed information about LIBNAMEoptions

librefis any SAS name that serves as an alias to associate SAS with a spreadsheet, datasource, or database. A SAS libref is an alias for a virtual or physical directory. Likethe global SAS LIBNAME statement, a SAS/ACCESS libref is an alias for aspreadsheet, database, or data source where your data is stored.

LISTlists the attributes of one or all SAS/ACCESS libraries or SAS libraries to the SASlog.

Specify the libref argument to list the attributes of a single library. Specify _ALL_to list the attributes of all the librefs in your current session.

PCFILESis the SAS/ACCESS engine for the interface to PC files on Linux and UNIX.

PC Files Server Connection OptionsSAS/ACCESS PC Files Connections Options

CONNECT_STRING=connection-stringspecifies connection options for your data source or database. Separate multipleoptions with a semicolon. This is an advanced connection method that you shoulduse only when you know the exact syntax of all connection options that the ODBCdriver requires for a successful connection.

DBPASSWORD=database-file-passwordenables you to access database files with database-level security. This securitylevel can be defined instead of user-level security.Alias: DBPWD|DBPW|PASS|PASSWORDRestriction: Access Database only.Note: Database password is case sensitive.

DBSYSFILE=workgroup-information-filespecifies the workgroup information file. This file contains a collection ofinformation defined for the Access database. User, group accounts, and passwordsthat you create, are saved in the workgroup information file.Alias: SYSTEMDBRestriction: Access database files only.

DSN=data-source-namespecifies the name of the ODBC data source that is used to access PC datathrough an ODBC driver on the PC.

Page 160: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

152 Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Chapter 12

Restriction: This ODBC data source must be defined on the PC where the PCFiles Server is running.

MSENGINE=ACE | JETdetermines the database engine to use for accessing Excel files or Access databases.The Microsoft Jet engine supports Microsoft formats up to 2003. The Microsoft Aceengine supports 2007 formats and formats in subsequent releases of Windows.Default: ACERestriction: It is recommended that this option is used only to create a Windows

95 format file.

PASSWORD=user-passwordspecifies a password required by the data source for the user account.Aliases: PWD|PW|PASS|PASSWORDNote: Passwords are case sensitive.

PATH=pathnamespecifies the full path and filename for your Access database or Excel file.

Example: Assign the libref db to an Excel file.

LIBNAME db pcfiles server=D2323 port=8621 path=’c:\demo.xls’;

Note: Always use the .mfb file extension for Access files and the .xls extension forExcel files.

PORT=port-numberspecifies the port number or service name that PC Files Server is listening to onthe PC.Aliases: SERVICE|SERVICE_NAMEDefault: 8621

SERVER=pc-server-host-namespecifies the name of the PC running PC Files Server. This name is required forLinux and UNIX users to connect to the server.Note: The name can be a simple computer name (wxp320), a fully qualified

network name (wxp320.domain.com), or an IP address.Restriction: Omitting the SERVER= value on 64-Bit Windows clients invokes

Autostart.

SERVERPASS=’server-user-password’specifies the password for the PC Files Server for the User ID given. If the accounthas no password, omit this option. Always enclose the value in quotes in order topreserve the case of the password.Alias: SERVERPASSWORD|SERVERPW|SERVERPWDNote: Passwords are generally case sensitive.Note: Use the PASSWORD= option for database passwords.Example: LIBNAME using explicit user name and password.

LIBNAME db pcfiles path=’C:\myfile.mdb’server=fileserv;serveruser=’mydomain\myusername’serverpass=’mypassword’;

SERVERUSER=’domain\server-user-name’specifies the domain name and User ID for the PC running PC Files Server.Always enclose the value in quotes, otherwise the backslash can be misinterpretedby the SAS parser.

Page 161: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Syntax for PC Files on Linux, UNIX, and 64-Bit

Microsoft Windows 153

Alias: SERVERUIDNote: If you are not on a domain, omit the domain name and the backslash.Note: Use the USER= option for database User IDs.Example: LIBNAME using explicit user name and password.

LIBNAME db pcfiles path=’C:\myfile.mdb’server=fileserv;serveruser=’mydomain\myusername’;serverpass=’mypassword’;

SSPI=YES|NOenables the PC Files Server to allow Integrated Windows Authentication. This is amechanism for the Windows client and server to exchange credentials.Default: NONote: SSPI can also be enabled by specifying the –SSPI option on the SAS

command line.Restriction: Microsoft Windows 64-Bit only.Example: LIBNAME using SSPI.

LIBNAME db pcfiles path=’C:\myfile.mdb’server=localhost;sspi=’yes’;

run;

TYPE=file-typespecifies the file type in the PATH= statement.Valid values: EXCEL|ACCESS.Note: Use TYPE= if the file identified in the PATH= statement does not have an

.xls or .mdb file extension.

USER=User IDspecifies a user account name, if one is required to connect to the data source. ForAccess, if you have user-level security set on your .mdb file, you need to use theUSER= and PASSWORD= options to access your file.Note: Use the SERVERUSER= option to connect to a server.Alias: UIDRestriction: Access database files only.

VERSION=2007|2003|2002|2000|97|95|5sets the version for a new Excel workbook.Alias: VERDefault: 97Note: Excel 2007, 2003, 2000, and 97 share the same file format. Excel 5 and 95

share a different file format.Restriction: Excel workbooks only.Note: You do not need to specify this option for an existing Excel file.

Details

Access Data Directly from a PC File

Page 162: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

154 Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Chapter 12

You can use SAS/ACCESS Interface to PC Files on Linux and UNIX to directlyaccess PC data from Linux and UNIX. You can read from and write to a variety of PCfile data residing on a PC, including Excel, Access, and any other ODBC data source.

The engine uses ODBC to support assigning a libref to Excel and Access files residingon a PC from Linux and UNIX. This enables you to reference spreadsheets, databases,and other ODBC data sources directly in a DATA step or a SAS procedure. You can alsoread from and write to an Access file or an Excel file as if it were a SAS data set.

Disassociating a Libref from a SAS LibraryTo disassociate or clear a libref, use a LIBNAME statement, specifying the libref(mypclib, for example) and this CLEAR option:

LIBNAME mypclib CLEAR;

You can clear a single specified libref or all current librefs.SAS/ACCESS disconnects from the data source and closes any free threads or

resources that are associated with that libref’s connection.

Writing SAS Library Attributes to the SAS LogUse a LIBNAME statement to write the attributes of one or more SAS/ACCESSlibraries or SAS libraries to the SAS log. Specify libref to list the attributes of a singleSAS/ACCESS library or SAS library, as shown.

LIBNAME mypclib LIST;

LIBNAME _ALL_ LIST;

Examples

Assigning a Libref to an Access Database

LIBNAME mymdb pcfiles server=D2323 port=8621 path=’c:\demo.mdb’;

The demo.mdb database contains a number of objects, including several tables, suchas Staff. After you assign a libref, you can reference the Access table like a SAS dataset. You can use it as a data source in any DATA step or SAS procedure. In this PROCSQL statement, MYMDB.STAFF is the two-level SAS name for the Staff table in theAccess database Demo.

PROC sql;select idnum, lname

from mymdb.staffwhere state=’NY’order by lname;

quit;

Create a SAS data set with Access.

data newds;set mymdb.staff(keep=idnum lname fname);

run;

SAS procedures such as PROC SQL, PROC PRINT, PROC CONTENTS, and PROCDATASETS , use the libref.

List all database objects in the library with the DATASETS procedure

Page 163: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Syntax for PC Files on Linux, UNIX, and 64-Bit

Microsoft Windows 155

PROC datasets library=mymdb;Quit;

To improve performance, it is recommended that you use the data set optionsINSERTBUFF= and READBUFF= and set an appropriate value.

Create a table named Invoice in an Access database from a SAS data set namedInvoice:

PROC SQL;Create table mymdb.Invoice (insertbuff=25) as select * from invoice;

Quit ;

Assigning a Libref to an Excel WorkbookCreate a libref, myxls, for an Excel workbook:

LIBNAME myxls pcfiles server=D2323 port=8621 path=’c:\demo.xls’;

The demo.xls workbook contains a number of sheets, such as sheet1. After youassign the libref, you can reference the Excel spreadsheet like a SAS data set and use itas a data source in any DATA step or SAS procedure. In this example, a SAS data setis created from an Excel sheet:

data a;set myxls.’sheet1$’n;

run;

When using a LIBNAME statement with Excel, refer to Excel sheets as n-literalsbecause of the “$” character. If you are referencing a named range in an Excelspreadsheet, it is not necessary to refer to it as an n-literal.

Reference a named range called page one in an Excel workbook:

data a;set myxls.pageone;

run;

Create an Excel file and use a SAS data set to populate a sheet in that file. Create anamed range for the sheet:

data myxls.air;set sashelp.air;

run;

Use the libref with any SAS procedure such as PROC SQL, PROC PRINT, PROCCONTENTS, and PROC DATASETS.

This SAS program uses the DATASETS procedure to list all database objects in thelibrary.

PROC datasets library=mymdb;Quit;

To improve performance, it is recommended that you use the data set optionREADBUFF= and set an appropriate value. This example reads in data from a rangecalled Invoice in an Excel workbook.

PROC SQL;Select * from myxls.Invoice (readbuff=25);

Quit;

Note: When writing to an Excel file, the PC Files Server does not support theINSERTBUFF= option with value greater than 1. �

Page 164: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

156 SAS LIBNAME Options for PC Files on Linux and UNIX � Chapter 12

Assigning a Libref to a Microsoft SQL Server DatabaseCreate a libref, mysqlsrv, to a SQL Server database via ODBC, using the server on

the PC:

LIBNAME mysqlsrv pcfiles server=D2323 port=8621 dsn=MQIS user=scottpwd=tiger schema=dbo;

Using the mysqlsrv libref, create a SAS data set called sqltest from the crime table inthe SQL Server database:

data work.sqltest;set mysqlsrv.crime;

run;

or

PROC sql;create table work.sqltest as select * from mysqlsrv.crime;

quit;

Using the mysqlsrv libref, create a SQL Server table called newtable from the SASdata set, sqltest:

data mysqlsrv.newtable;set sqltest;

run;

Assigning a Libref to an Oracle DatabaseCreate a libref, ora, to an Oracle database table via ODBC, using the PC Files Server

on the PC:

LIBNAME ora pcfiles server=D2323 port=8621 dsn=ORA9MSuser=scott pwd=tiger preserve_tab_names=yes;

Using the ora libref, an Oracle table, oratab, is created from a SAS data setsashelp.class:

data ora.oratab;set sashelp.class;

run;

Using the ora libref, a SAS data set, sastab, is created from the Oracle table emp:

data sastab;set ora.emp;

run;

SAS LIBNAME Options for PC Files on Linux and UNIX

The followingSAS LIBNAME statement options provide enhanced control over theway that SAS processes PC files data.

Many of these LIBNAME options are also available as data set options .

Note: Note that these are advanced options that do not need to be specified formany of the tasks you perform. �

ACCESS=READONLYindicates that tables and views can be read but not updated.

AUTOCOMMIT=YES|NO

Page 165: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � SAS LIBNAME Options for PC Files on Linux and

UNIX 157

determines whether the ACCESS engine commits (saves) updates as soon as theuser submits them.

YESspecifies that updates are committed to a table as soon as they are submitted,and no rollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commitwhen it reaches the end of the file.

Default: NO

COMMAND_TIMEOUT=number-of-secondsspecifies the number of seconds that pass before a data source command times out.

Default: 0 (no time-out)

Alias: TIMEOUT

CONNECTION=SHAREDREAD|UNIQUE|GLOBALREADdetermines whether operations against a single libref share a connection to thedata source. Also determines whether operations against multiple librefs share aconnection to the data source.

SHAREDREADspecifies that all READ operations that access data source tables in a singlelibref share a single connection. A separate connection is established for eachtable that is opened for update or output operations.

Where available, this is usually the default value because it offers the bestperformance and it guarantees data integrity.

UNIQUEspecifies that a separate connection is established every time a data sourcetable is accessed by your SAS application.

Use UNIQUE if you want each use of a table to have its own connection.

GLOBALREADspecifies that all READ operations that access data source tables in multiplelibrefs share a single connection if these conditions are met:

� the participating librefs are created by LIBNAME statements thatspecify identical values for the CONNECTION= option andCONNECTION_GROUP= option.

� the participating librefs are created by LIBNAME statements thatspecify identical values for any data source connection options.

A separate connection is established for each table that is opened for updateor output operations.

GLOBALREAD is the default value for CONNECTION= option when youspecify CONNECTION_GROUP= option.

Default: SHAREDREAD

CONNECTION_GROUP=connection-groupcauses operations against multiple librefs to share a connection to the data source.Also causes operations against multiple Pass-Through Facility CONNECTstatements to share a connection to the data source.

CURSOR_TYPE=DYNAMIC|FORWARD_ONLY|KEYSET_DRIVEN|STATICspecifies the cursor type for read-only cursors and for cursors to be updated.

DYNAMIC

Page 166: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

158 SAS LIBNAME Options for PC Files on Linux and UNIX � Chapter 12

specifies that the cursor reflects all changes that are made to the rows in aresult set as you move the cursor. The data values and the membership ofrows in the cursor can change dynamically on each fetch. This is the defaultfor the DB2 UNIX, PC files, and the SQL Server interfaces.

FORWARD_ONLYspecifies that the cursor behaves like a DYNAMIC cursor, except that it onlysupports fetching the rows sequentially.

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set whenthe cursor is opened. Note that changes that are made to these rows arereflected as you scroll around the cursor.

STATICspecifies that the complete result set is built when the cursor is opened. Nochanges that are made to the rows in the result set after the cursor is openedare reflected in the cursor. Static cursors are read-only.

Alias: CURSOR

DBCOMMIT=number-of-rowsaffects update, delete, and insert processing. The number of rows that areprocessed includes rows that are not processed successfully. If you setDBCOMMIT=0, a commit is issued only once (after the procedure or DATA stepcompletes). If the DBCOMMIT= option is explicitly set, SAS/ACCESS fails anyupdate that has a WHERE clause.

Note: If you specify both DBCOMMIT= and ERRLIMIT=, and these optionscollide during processing, then the commit is issued first and the rollback is issuedsecond. Because the commit (caused by the DBCOMMIT= option) is issued beforethe rollback (caused by the ERRLIMIT= option), the DBCOMMIT= option is saidto override the ERRLIMIT= option in this situation. �

Default: 1,000 (inserting) or 0 (updating; commit occurs when data set orprocedure completes)

DBGEN_NAME=DBMS| SASspecifies that the data source columns are renamed and the format that the namesfollow.

DBMSspecifies that the data source columns are renamed to valid SAS variablenames. Disallowed characters are converted to underscores. If a column isconverted to a name that already exists, then a sequence number is appendedto the end of the new name.

SASspecifies that data source columns are renamed to the format _COLn, wheren is the column number (starting with zero).

Default: DBMS

DBMAX_TEXT=nspecifies an integer between 1 and 32,767 that indicates the maximum length for acharacter string. Longer character strings are truncated. This option applies onlywhen you are reading, appending, and updating character data in an Accessdatabase or Excel workbook from SAS. Although you can specify a value less than256, it is not recommended for reading data from an Access database.Default: 1,024

DBNULLKEYS=YES|NO

Page 167: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � SAS LIBNAME Options for PC Files on Linux and

UNIX 159

specifies column definitions.

YESIf there might be NULL values in the transaction table or the master tablefor the columns that you specify in the DBKEY= option, useDBNULLKEYS=YES. When you specify DBNULLKEYS=YES and specify acolumn that is not defined as NOT NULL in the DBKEY= data set option,SAS generates a WHERE clause that can find NULL values. For example, ifyou specify DBKEY=COLUMN and COLUMN is not defined as NOT NULL,SAS generates a WHERE clause with this syntax:

WHERE ((COLUMN =?) OR ((COLUMN IS NULL) AND (? IS NULL)))

This syntax enables SAS to prepare the statement once and use it for anyvalue (NULL or NOT NULL) in the column. Note that this syntax has thepotential to be much less efficient than the shorter form of the WHEREclause (presented below).

NOWhen you specify DBNULLKEYS=NO or specify a column that is defined asNOT NULL in the DBKEY= option, SAS generates a simple WHERE clause.If you know that there are no NULL values in the transaction table or themaster table for the columns that you specify in the DBKEY= option, thenyou can use DBNULLKEYS=NO. If you specify DBNULLKEYS=NO andspecify DBKEY=COLUMN, SAS generates a shorter form of the WHEREclause (regardless of whether or not the column specified in DBKEY= isdefined as NOT NULL):

WHERE (COLUMN =?)

Default: YES

DBSASLABEL=COMPAT|NONEspecifies whether SAS/ACCESS saves the data source column names as SAS labelnames. This option is valid only when you are reading data into SAS from thedata source.

Default: COMPAT

DEFER=NO|YESenables you to specify when the connection to the data source occurs.

NOspecifies that the connection to the data source occurs when the libref isassigned by a LIBNAME statement.

YESspecifies that the connection to the data source occurs when a table in thedata source is opened.

Default: NO

DIRECT_SQL=YES|NO|NONE| specific-functionalityspecify whether generated SQL is passed to the data source for processing.

YESspecifies that, whenever possible, generated SQL, except multiple outer joins,is passed to the data source for processing. This includes SQL that isgenerated from PROC SQL, SAS functions that can be converted into datasource functions, joins, and WHERE clauses.

NO

Page 168: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

160 SAS LIBNAME Options for PC Files on Linux and UNIX � Chapter 12

specifies that generated SQL from PROC SQL is not passed to the datasource for processing. This is the same as specifying the specific-functionalityvalue NOGENSQL.

NONEspecifies that generated SQL is not passed to the data source for processing.This includes SQL that is generated from PROC SQL, SAS functions that canbe converted into data source functions, joins, and WHERE clauses.

specific-functionalityidentifies types of processing to be handled by SAS instead of the data source.You can specify these values:

NOFUNCTIONScauses SAS to handle all SAS functions. The SAS functions are notconverted into data source functions and are not passed to the datasource for processing.

NOMULTOUTJOINScauses SAS to process outer joins that involve more than two tables.This option does not affect outer joins of two tables.

Note: This option is always turned ON for the Jet engine. �

NOGENSQLprevents PROC SQL from generating SQL to pass to the data source forprocessing.

NOWHEREprevents WHERE clauses from being passed to the data source forprocessing. This includes SAS WHERE clauses and PROCSQL-generated or PROC SQL0specified WHERE clauses.

Default: YES

INSERTBUFF=number-of-rowsspecifies the number of rows for a multiple-row insert. The value forINSERTBUFF= must be a positive number. If the INSERTBUFF= value is greaterthan the DBCOMMIT= value, the DBCOMMIT= value overrides it. When youassign a value that is greater than INSERTBUFF=1, the SAS application notesthat indicate the success or failure of the insert operation might be incorrectbecause these notes represent information only for a single insert, even whenmultiple inserts are performed.

Default: 1

READBUFF=number-of-rowsspecifies the number of rows to use when you are reading data from a data source.Setting a higher value for this option reduces I/O and increases performance, butalso increases memory usage. Additionally, if too many rows are read at once,values returned to SAS might be out of date.

Default: 1

Alias: ROWSET|ROWSET_SIZE

SCAN_TEXTSIZE=YES|NOspecifies whether to scan the length of text data for a data source column and usethe length of the longest string data found as the SAS column width.

YESscans the length of text data for a data source column and use the length ofthe longest string data found as the SAS variable width. However, if the

Page 169: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � SAS LIBNAME Options for PC Files on Linux and

UNIX 161

maximum length found is greater than what is specified in theDBMAX_TEXT= option, the smaller value that is specified inDBMAX_TEXT= is applied as the SAS variable width.

For Excel, this option applies to all character data type columns. ForAccess, this applies only to the MEMO data type field and does not apply tothe TEXT (less than 256 characters long) field.

NOdoes not scan the length of text data for a data source column. The columnlength returned from the Jet provider is used as the SAS variable width.However, if the returned column width is greater than what is specified inthe DBMAX_TEXT= option, the smaller value specified in DBMAX_TEXT= isapplied as the SAS variable width.

Note: Specify SCANTEXT=NO when you need to update data in theAccess database or Excel workbook. �

Default: YES for an Excel workbookNO for an Access database

Alias: SCANTEXT| SCANMEMO

SCAN_TIMETYPE=YES|NOspecifies whether to scan all row values for a DATETIME data type field andautomatically determine the TIME data type based on the setting. Option valuesYES turn on the scan function. Option value NO turns off the scan function.

YESspecifies that a column with all time values (internal value is less than 1) isassigned a TIME8. format.

NOspecifies that a column with date/time values is assigned a DATE9. format orDATETIME19 format. Please refer to USE_DATETYPE= option for moreinformation.

Default: NOAlias: SCAN_TIME| SCANTIME

SPOOL=YES|NOspecifies whether SAS creates a utility spool file during read transactions thatread data more than once.

YESspecifies that SAS creates a utility spool file into which it writes the rowsthat are read the first time. For subsequent passes through the data, therows are read from the utility spool file rather than being reread from thedata source table. This guarantees that the row set is the same for everypass through the data.

NOspecifies that the required rows for all passes of the data are read from thedata source table. No spool file is written. There is no guarantee that the rowset is the same for each pass through the data.

Default: YES

STRINGDATES=YES|NOspecifies whether datetime values are read from the data source as characterstrings or as numeric date values. STRINGDATES= is not available as a data setoption.

YES

Page 170: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

162 Data Set Options for PC Files on Linux and UNIX, and 64-Bit Windows � Chapter 12

specifies that SAS/ACCESS reads datetime values as character strings.

NOspecifies that SAS/ACCESS reads datetime values as numeric date values.

Default: NOAlias: STRDATES

USE_DATETYPE=YES|NOspecifies whether to use DATE. format for datetime columns in the data sourcetable while importing data from an Access database or Excel workbook.

YESspecifies that the SAS DATE format is assigned for datetime columns in thedata source table.

NOspecifies that the SAS DATETIME format is assigned for datetime columns inthe data source table.

Default: YES for an Excel workbookNO for an Access database

Alias: USE_DATE|USEDATE

Data Set Options for PC Files on Linux and UNIX, and 64-Bit WindowsYou can specify SAS/ACCESS data set options on a SAS data set when you access PC

files data with the “Syntax for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows”on page 150. A data set option applies only to the data set on which it is specified, andit remains in effect for the duration of the DATA step or procedure.

This generic example shows the format of data set options:

LIBNAME libref engine-name;PROC PRINT libref.data-set-name(DATA_SET_OPTION=value)

You can use the CNTLLEV=, DROP=, FIRSTOBS=, IN=, KEEP=, OBS=, RENAME=,and WHERE= SAS data set options when you access PC files data. The REPLACE=SAS data set option is not supported by SAS/ACCESS interfaces. For information aboutusing SAS data set options, refer to the SAS Language Reference: Dictionary.

Note: Specifying data set options in PROC SQL might reduce performance, becauseit prevents operations from being passed to the data source for processing. �

AUTOCOMMIT= Data Set OptionDetermines whether the ACCESS engine commits (saves) updates as soon as the user submitsthem.

Valid in: DATA and PROC stepsDefault:LIBNAME option setting

SyntaxAUTOCOMMIT=YES|NO

Page 171: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � CURSOR_TYPE= Data Set Option 163

Syntax Description

YESspecifies that updates are committed to a table as soon as they are submitted, and norollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commit when itreaches the end of the file.

COMMAND_TIMEOUT= Data Set Option

Specifies the number of seconds to wait before a command times out.

Valid in: DATA and PROC steps

Default value: LIBNAME option setting

SyntaxCOMMAND_TIMEOUT=number-of-seconds

See AlsoTo assign this option to a group of tables, use the COMMAND_TIMEOUT= option

specified in “LIBNAME Options” on page 85.

CURSOR_TYPE= Data Set Option

Specifies the cursor type for read-only cursors and cursors to update.

Valid in: DATA and PROC steps

Default value: none

Alias: CURSOR

SyntaxCURSOR_TYPE=DYNAMIC|FORWARD_ONLY|KEYSET_DRIVEN|STATIC

Syntax Description

DYNAMIC

Page 172: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

164 DBCOMMIT= Data Set Option � Chapter 12

specifies that the cursor reflects all changes that are made to the rows in a result setas you move the cursor. The data values and the membership of rows in the cursorcan change dynamically on each fetch. This is the default for the DB2 UNIX, PCfiles, and SQL Server interfaces.

FORWARD_ONLYspecifies that the cursor behaves like a DYNAMIC cursor, except that it supportsonly fetching the rows sequentially.

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set when thecursor is opened. Note that changes that are made to these rows are reflected as youscroll around the cursor.

STATICspecifies that the complete result set is built when the cursor is opened. No changesthat are made to the rows in the result set after the cursor is opened are reflected inthe cursor. Static cursors are read-only.

See AlsoTo assign this option to a group of tables, use the CURSOR_TYPE= option specified

in “LIBNAME Options” on page 85.

DBCOMMIT= Data Set Option

Lets you issue a commit statement automatically after a specified number of rows have beenprocessed.

Valid in: DATA and PROC stepsDefault value: LIBNAME option setting

SyntaxDBCOMMIT=number-of-rows

Syntax Description

number-of-rowsis an integer greater than or equal to 0.

DetailsDBCOMMIT= affects update, delete, and insert processing. The number of rowsprocessed includes rows that are not processed successfully. When DBCOMMIT=0, acommit is issued only once—after the procedure or DATA step completes.

If the DBCOMMIT= option is explicitly set, SAS/ACCESS fails any update that has aWHERE clause.

Note: If you specify both DBCOMMIT= and ERRLIMIT= , and these options collideduring processing, then the commit is issued first and the rollback is issued second.

Page 173: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � DBCREATE_TABLE_OPTS= Data Set

Option 165

Because the commit (caused by the DBCOMMIT= option) is issued before the rollback(caused by the ERRLIMIT= option), the DBCOMMIT= option is said to override theERRLIMIT= option in this situation. �

Example

In this example, a commit is issued after every 10 rows are inserted:

data myxls.dept(dbcommit=10);set mysas.staff;

run;

See AlsoTo assign this option to a group of tables, use the DBCOMMIT= option specified in

“LIBNAME Options” on page 85.

DBCONDITION= Data Set OptionSpecifies criteria for subsetting and ordering data.

Valid in: DATA and PROC stepsDefault value: none

SyntaxDBCONDITION=SQL-query-clause

Syntax Description

SQL-query-clauseis a data source-specific SQL query clause, such as WHERE, GROUP BY, HAVING,or ORDER BY.

DetailsThis option enables you to specify selection criteria in the form of data source-specificSQL query clauses, which the SAS/ACCESS engine passes directly to the data sourcefor processing. When selection criteria are passed directly to the data source forprocessing, performance is often enhanced. The data source checks the criteria forsyntax errors when it receives the SQL query.

The DBKEY= option is ignored when you use DBCONDITION= option.

DBCREATE_TABLE_OPTS= Data Set OptionSpecifies data source-specific syntax to add to the CREATE TABLE statement.

Page 174: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

166 DBFORCE= Data Set Option � Chapter 12

Valid in: DATA and PROC steps

Default value: LIBNAME option setting

SyntaxDBCREATE_TABLE_OPTS=’SQL-clauses’

Syntax Description

SQL-clausesare one or more data source-specific clauses that can be appended to the end of anSQL CREATE TABLE statement.

DetailsThis option enables you to add data source-specific clauses to the end of the SQLCREATE TABLE statement. The SAS/ACCESS engine passes the SQL CREATETABLE statement and its clauses to the data source, which executes the statement andcreates the table.

See AlsoTo assign this option to a group of tables, use the DBCREATE_TABLE_OPTS= option

specified in “LIBNAME Options” on page 85.

DBFORCE= Data Set Option

Specifies whether to force the truncation of data during insert processing.

Valid in: DATA and PROC steps

Default value: NO

SyntaxDBFORCE=YES|NO

Syntax Description

YESspecifies that the rows that contain data values that exceed the length of the columnare inserted, and the data values are truncated to fit the column length.

NOspecifies that the rows that contain data values that exceed the column length arenot inserted.

Page 175: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � DBGEN_NAME= Data Set Option 167

Details

This option determines how the SAS/ACCESS engine handles rows that contain datavalues that exceed the length of the column.

The SAS data set option FORCE= overrides this option when it is used with PROCAPPEND or the PROC SQL UPDATE statement. The PROC SQL UPDATE statementdoes not provide a warning before truncating the data.

DBGEN_NAME= Data Set Option

Specifies whether to rename columns automatically when they contain disallowed characters.

Valid in: DATA and PROC steps

Default value: LIBNAME option setting

Syntax

DBGEN_NAME=DBMS|SAS

Syntax Description

DBMSspecifies that disallowed characters are converted to underscores.

SASspecifies that columns that contain disallowed characters are converted into validSAS variable names, using the format _COLn, where n is the column number(starting with zero). If a name is converted to a name that already exists, a sequencenumber is appended to the end of the new name.

Details

SAS retains column names when reading data, unless a column name containscharacters that SAS does not allow, such as $ or @. SAS allows alphanumericcharacters and the underscore (_).

This option is intended primarily for National Language Support, notably theconversion of kanji to English characters because the English characters that areconverted from kanji are often not allowed in SAS. If you specify DBGEN_NAME=SAS,a column named DEPT$AMT is renamed to _COLn where n is the column number. Ifyou specify DBGEN_NAME=DBMS, a column named DEPT$AMT is renamed toDEPT_AMT.

See Also

To assign this option to a group of tables, use the DBGEN_NAME= option specifiedin “LIBNAME Options” on page 85.

Page 176: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

168 DBKEY= Data Set Option � Chapter 12

DBKEY= Data Set Option

Improves performance by specifying a column to use as an index when you process a join thatinvolves a large data source table and a small SAS data set.

Valid in: DATA and PROC stepsDefault value: none

SyntaxDBKEY=(<’>column-1<’> <... <’>column-n<’>>)

Syntax Description

columnis the name of the column that forms the index on the data source table.

DetailsWhen processing a join that involves a large data source table and a relatively smallSAS data set, you might be able to use DBKEY= to improve performance.

CAUTION:Improper use of this option can harm performance. �

DBLABEL= Data Set Option

Specifies whether to use SAS variable labels as data source column names during outputprocessing.

Valid in: DATA and PROC stepsDefault value: NO

SyntaxDBLABEL=YES|NO

Syntax Description

YESspecifies that SAS variable labels are used as data source column names duringoutput processing.

NOspecifies that SAS variable names are used as data source column names.

Page 177: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � DBMAX_TEXT= Data Set Option 169

DetailsThis option is valid only for creating data source tables.

Note: Only up to 64 characters of SAS variable labels are written to an Access or anExcel file. �

Example

In this example, the SAS data set New is created with one variable C1. This variableis assigned a label of DeptNum. In the second DATA step, the MyDBLib.MyDept tableis created by using DeptNum as the data source column name. When DBLABEL=YES,you can use the label as the column name.

data new;label c1=’deptnum’;c1=001;

run;

data mydblib.mydept(dblabel=yes);set new;

run;

PROC print data=mydblib.mydept;run;

DBMAX_TEXT= Data Set Option

Determines the length of a very long data source character data type that is read into SAS orwritten from SAS when you are using a SAS/ACCESS engine.

Valid in: DATA and PROC stepsDefault value: LIBNAME option setting

SyntaxDBMAX_TEXT= integer

Syntax Description

integeris a number between 1 and 32,767.

DetailsThis option applies to reading, appending, and updating rows in an existing table. Itdoes not apply when you are creating a table.

DBMAX_TEXT= is usually used with a very long character data type.

Page 178: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

170 DBNULL= Data Set Option � Chapter 12

Although you can specify a value less than 256, it is not recommended for readingdata from an Access database.

See AlsoTo assign this option to a group of tables, use the DBMAX_TEXT= option specified in

“LIBNAME Options” on page 85.

DBNULL= Data Set OptionIndicates whether NULL is a valid value for the specified columns when a table is created.

Valid in: DATA and PROC stepsDefault value: YES

SyntaxDBNULL= (column-name-1=YES|NO <...column-name-n=YES|NO >

|_ALL_=YES|NO)

Syntax Description

YESspecifies that the NULL value is valid for the specified columns.

NOspecifies that the NULL value is not valid for the specified columns.

DetailsThis option is valid only for creating data source tables. If you specify more than onecolumn name, the names must be separated with spaces.

The DBNULL= option processes values from left to right, so if you specify a columnname twice, or if you use the _ALL_ value, the last value overrides the first valuespecified for the column.

Only the Access engine—not the Excel engine—supports this option.

Examples

In this example, by using the DBNULL= option, the EmpId and Jobcode columns inthe new MyDBLib.MyDept2 table are prevented from accepting null values. If theEmployees table contains null values in the EmpId or Jobcode columns, the DATA stepfails.

data mydblib.mydept2(dbnull=(empid=no jobcode=no));set mydblib.employees;

run;

In this example, all columns in the new MyDBLib.MyDept3 table except for theJobcode column are prevented from accepting null values. If the Employees tablecontains null values in any column other than the Jobcode column, the DATA step fails.

Page 179: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � DBSASTYPE= Data Set Option 171

data mydblib.mydept3(dbnull=(_ALL_=no jobcode=YES));set mydblib.employees;

run;

DBNULLKEYS= Data Set Option

Controls the format of the WHERE clause when you use the DBKEY= data set option.

Valid in DATA and PROC stepsDefault value LIBNAME setting

SyntaxDBNULLKEYS= YES|NO

DetailsIf there might be NULL values in the transaction table or the master table for thecolumns that you specify in the DBKEY= option, then use DBNULLKEYS=YES. Whenyou specify DBNULLKEYS=YES and specify a column that is not defined as NOTNULL in the DBKEY= data set option, SAS generates a WHERE clause that can findNULL values. For example, if you specify DBKEY=COLUMN and COLUMN is notdefined as NOT NULL, SAS generates a WHERE clause with the following syntax.

WHERE ((COLUMN = ?) OR ((COLUMN IS NULL) AND (? IS NULL)))

This syntax enables SAS to prepare the statement once and use it for any value (NULLor NOT NULL) in the column. Note that this syntax has the potential to be much lessefficient than the shorter form of the WHERE clause (presented below). When youspecify DBNULLKEYS=NO or specify a column that is defined as NOT NULL in theDBKEY= option, SAS generates a simple WHERE clause.

If you know that there are no NULL values in the transaction table or the mastertable for the columns that you specify in the DBKEY= option, you can useDBNULLKEYS=NO. If you specify DBNULLKEYS=NO and specifyDBKEY=COLUMN, SAS generates a shorter form of the WHERE clause (regardless ofwhether or not the column specified in DBKEY= is defined as NOT NULL):

WHERE (COLUMN = ?)

See AlsoTo assign this option to a group of tables, use the DBNULLKEYS= option specified in

“LIBNAME Options” on page 85.

DBSASTYPE= Data Set Option

Specifies one or more data types to override one or more default SAS data types during inputprocessing of data.

Page 180: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

172 DBTYPE= Data Set Option � Chapter 12

Valid in: DATA and PROC stepsDefault value: none

SyntaxDBSASTYPE=(column-name-1=<’>SAS-data-type<’>

<...column-name-n=<’>SAS-data-type<’>>)

Syntax Description

column-namespecifies a data source column name.

SAS data-typespecifies a SAS data type. SAS data types include CHAR(n), NUMERIC,DATETIME, DATE, TIME.

DetailsBy default, SAS/ACCESS converts each data source data type to a SAS data typeduring input processing. When you need a different data type, you can use this optionto override the default and assign a SAS data type to each specified data source column.Some conversions might not be supported. If a conversion is not supported, SAS printsan error to the log.

DBTYPE= Data Set Option

Specifies a data type to use instead of the default data source data type when SAS creates a datasource table.

Valid in: DATA and PROC steps

Default value: none

SyntaxDBTYPE=(column-name-1=<’>data-source-type<’>

<...column-name-n=<’>data-source-type<’>>)

Syntax Description

column-namespecifies a data source column name.

data-source-typespecifies a data source data type. See the documentation for your SAS/ACCESSinterface for the default data types for your data source.

Page 181: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � ERRLIMIT= Data Set Option 173

DetailsBy default, SAS/ACCESS converts each SAS data type to a predetermined data sourcedata type when outputting data to your data source. When you need a different datatype, use DBTYPE= to override the default data type chosen by the SAS/ACCESSengine.

Example

In this example, DBTYPE= specifies the data types that are used when you createcolumns in the table.

data mydblib.newdept(dbtype=(deptno=’double’ city=’char(25)’));set mydblib.dept;

run;

ERRLIMIT= Data Set Option

Specifies the number of errors that are allowed before SAS stops processing and issues a rollback.

Valid in: DATA and PROC steps

Default value: 1

SyntaxERRLIMIT=integer

Syntax Description

INTEGERis a positive integer that represents the number of errors after which SAS stopsprocessing and issues a rollback.

DetailsSAS calls the data source to issue a rollback after a specified number of errors occursduring the processing of inserts, deletes, updates, and appends. If ERRLIMIT= is set to0, SAS processes all rows, regardless of the number of errors that occur. The SAS logdisplays the total number of rows processed and the number of failed rows, if applicable.

The DBCOMMIT= option overrides the ERRLIMIT= option. If you specify a value forDBCOMMIT= other than zero, then rollbacks affected by the ERRLIMIT= option mightnot include records that are processed unsuccessfully because they were alreadycommitted by DBCOMMIT= option.

Note: This option cannot be used from a SAS client session in a SAS/SHAREenvironment. �

Page 182: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

174 INSERT_SQL= Data Set Option � Chapter 12

Example

In this example, SAS stops processing and issues a rollback to the data source at theoccurrence of the tenth error. The MyDBLib libref was assigned in a prior LIBNAMEstatement.

data mydblib.employee3 (errlimit=10);set mydblib.employees;where salary > 40000;

run;

INSERT_SQL= Data Set Option

Determines the method to use to insert rows into a data source.

Valid in: DATA and PROC steps

Default value: LIBNAME option setting

SyntaxINSERT_SQL=YES|NO

Syntax Description

YESspecifies that the SAS/ACCESS engine uses the data source’s SQL insert method toinsert new rows into a table.

NOspecifies that the SAS/ACCESS engine uses an alternate (data source-specific)method to add new rows to a table.

See AlsoTo assign this option to a group of tables, use the INSERT_SQL= option specified in

“LIBNAME Options” on page 85.

INSERTBUFF= Data Set Option

Specifies the number of rows in a single insert.

Valid in: DATA and PROC steps

Default value: LIBNAME option setting

Page 183: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � NULLCHAR= Data Set Option 175

SyntaxINSERTBUFF=number-of-rows

Syntax Description

number-of-rowsspecifies the number of rows to insert. The value must be a positive integer.

DetailsSAS allows the maximum number of rows that is allowed by the data source. Theoptimal value for this option varies with factors such as network type and availablememory. You might need to experiment with different values to determine the bestvalue for your site.

When you assign a value that is greater than INSERTBUFF=1, the SAS applicationnotes that indicate the success or failure of the insert operation might be incorrectbecause these notes represent only information for a single insert, even when multipleinserts are performed.

Note: PC Files Server does not support INSERTBUFF= option with a value higherthan 1 for writing data to Excel. It ignores this option when writing data to Excel. �

If the DBCOMMIT= option is specified with a value that is less than the value ofINSERTBUFF=, then DBCOMMIT= overrides INSERTBUFF= option.

Note: When you are inserting with the VIEWTABLE window or the FSEDIT orFSVIEW procedure, use INSERTBUFF=1 to prevent the data source interface fromtrying to insert multiple rows. These features do not support inserting more than onerow at a time. �

See AlsoTo assign this option to a group of tables, use the INSERTBUFF= option specified in

“LIBNAME Options” on page 85.

NULLCHAR= Data Set Option

Indicates how SAS character missing values are handled during insert, update, and DBKEY=processing.

Valid in: DATA and PROC stepsDefault value: SAS

SyntaxNULLCHAR= YES|NO

Syntax Description

Page 184: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

176 NULLCHARVAL= Data Set Option � Chapter 12

YESindicates that character missing values in SAS data sets are treated as NULL valuesif the data source allows them. Otherwise, an error is returned.

NOindicates that character missing values in SAS data sets are treated as theNULLCHARVAL= value, regardless of whether the data source allows NULLs for thecolumn.

DetailsThis option affects insert and update processing and also applies when you use theDBKEY= option.

This option works in conjunction with the NULLCHARVAL= data set option.NULLCHARVAL= determines what is inserted when NULL values are not allowed.

All SAS numeric missing values (represented in SAS as ’.’) are treated by the datasource as NULLs.

NULLCHARVAL= Data Set Option

Defines the character string that replaces SAS character missing values during insert, update, andDBKEY= processing.

Valid in: DATA and PROC stepsDefault value: a blank character

SyntaxNULLCHARVAL=’character-string’

DetailsThis option affects insert and update processing and also applies when you use theDBKEY= option.

This option works with the NULLCHAR= option. NULCHAR= determines whetheror not a SAS character NULL value is treated as a NULL value.

If NULLCHARVAL= is longer than the maximum column width, one of these actionsoccurs:

� The string is truncated if DBFORCE=YES.� The operation fails if DBFORCE=NO.

READBUFF= Data Set Option

Specifies the number of rows of data to read into the buffer.

Valid in: DATA and PROC stepsDefault value: LIBNAME option setting

Page 185: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

LIBNAME Statement: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � SASDATEFMT= Data Set Option 177

SyntaxREADBUFF=number-of-rows

Syntax Description

number-of-rowsis the maximum value that is allowed by the data source.

DetailsThis option improves performance by specifying a number of rows that can be held inmemory for input into SAS. Buffering data reads can decrease network activities andincrease performance. However, because SAS stores the rows in memory, higher valuesfor READBUFF= use more memory. In addition, if too many rows are selected at once,then the rows that are returned to the SAS application might be out of date.

When READBUFF=1, only one row is retrieved at a time. The higher the value forREADBUFF=, the more rows the SAS/ACCESS engine retrieves in one fetch operation.

ROWSET_SIZE is an alias for this option.

See AlsoTo assign this option to a group of tables, use the READBUFF= option specified in

“LIBNAME Options” on page 85.

SASDATEFMT= Data Set Option

Changes the SAS date format of a data source column.

Valid in: DATA and PROC steps

Default value: none

SyntaxSASDATEFMT=(data-source-date-column-1=’SAS date-format’

<... data-source-date-column-n=’SAS date-format’>)

Syntax Description

data-source-date-columnspecifies the name of a date column in a data source table.

SAS date-formatspecifies a SAS date format that has an equivalent (like-named) informat. Forexample, DATETIME21.2 is both a SAS format and a SAS informat, so it is a validvalue for the SAS date-format argument.

Page 186: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

178 SASDATEFMT= Data Set Option � Chapter 12

DetailsIf the date format of a SAS column does not match the date format of the correspondingdata source column, you must convert the SAS date values to the appropriate datasource date values. The SAS DATEFMT= option enables you to convert date valuesfrom the default SAS date format to another SAS date format that you specify.

Use SAS DATEFMT= to prevent date type mismatches under these circumstances:

� during input operations to convert data source date values to the correct SASDATE, TIME, or DATETIME values

� during output operations to convert SAS DATE, TIME, or DATETIME values tothe correct data source date values

If the SAS date format and the data source date format match, this option is notneeded.

The default SAS date format is data source-specific and is determined by the datatype of the data source column. See the documentation for your SAS/ACCESS interface.

Note: For non-English date types, SAS automatically converts the data to the SAStype of NUMBER. The SAS DATEFMT= option does not currently handle these datetypes, but you can use a PROC SQL view to convert the data source data to a SAS dateformat as you retrieve the data, or use a format statement in other contexts. �

Page 187: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

179

C H A P T E R

13Pass-Through Facility: PC Fileson Linux, UNIX, and 64-BitMicrosoft Windows

Overview: Pass-Through Facility for PC Files on Linux, UNIX, and 64-Bit Microsoft Windows 179Syntax for the Pass-Through Facility for PC Files 180

Return Codes 181

CONNECT Statement 181

DISCONNECT Statement 186

EXECUTE Statement 187Special PC Files Queries 190

Overview: Pass-Through Facility for PC Files on Linux, UNIX, and64-Bit Microsoft Windows

The SQL procedure implements the Structured Query Language (SQL) for SAS. Seethe SQL procedure topic in Base SAS Procedures Guide for information about PROCSQL. You can send data source-specific SQL statements directly to a data source usingan extension to the SQL procedure called the Pass-Through Facility.

This facility uses SAS/ACCESS to connect to a data source and to send statementsdirectly to the data source for execution. This facility is a complement to theSAS/ACCESS LIBNAME statement. It enables you to use the SQL syntax of your datasource, which can include any non-ANSI standard SQL that is supported by your datasource.

Using the Pass-Through Facility, here is what you can do:

� establish and terminate connections with a data source using its CONNECT andDISCONNECT statements

� send dynamic, non-query, data source-specific SQL statements to a data sourceusing its EXECUTE statement

� retrieve data directly from a data source using its CONNECTION TO componentin the FROM clause of a PROC SQL SELECT statement

You can use Pass-Through Facility statements in a PROC SQL query or you canstore them in a PROC SQL view. When you create a PROC SQL view, any argumentsthat you specify in the CONNECT statement are stored with the view. Therefore, whenthe view is used in a SAS program, SAS can establish the appropriate connection to thedata source.

Page 188: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

180 Syntax for the Pass-Through Facility for PC Files � Chapter 13

Syntax for the Pass-Through Facility for PC Files

This section contains syntax for the Pass-Through Facility statements and theCONNECTION TO component. You can use the component with the PROC SQLSELECT statement to query data from a data source.

Page 189: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � CONNECT Statement 181

PROC SQL <options-list>;

CONNECT TO data-source-name <AS alias> <(<connect-statement-arguments><database-connection-arguments>)>;

DISCONNECT FROM data-source-name | alias;

EXECUTE (data-source-specific-SQL-statement) BY data-source-name | alias;

SELECT column-list FROM CONNECTION TO data-source-name | alias(data-source-query)

Return CodesAs you use the PROC SQL statements that are available in the Pass-Through

Facility, any error conditions are written to the SAS log. The Pass-Through Facilitygenerates return codes and messages that are available to you through the followingtwo SAS macro variables:

SQLXRCcontains the data source return code that identifies the data source error.

SQLXMSGcontains descriptive information about the data source error that is generated bythe data source.

The contents of the SQLXRC and SQLXMSG macro variables are printed in the SASlog using the %PUT macro. They are reset after each Pass-Through Facility statementhas been executed.

CONNECT Statement

Establishes a connection with the data source.

Valid in: PROC SQL steps

SyntaxCONNECT TO data-source-name <AS alias> <(<connect-statement-arguments>

<database-connection-arguments>)>;

Argumentsdata-source-name

identifies the data source to which you want to connect. Since this methodrequires connecting through the PC Files Server, you must use PCFILES as yourdata source. You can also specify an optional alias in the CONNECT statement.

aliasspecifies an optional alias for the connection that has 1 to 32 characters. If youspecify an alias, the keyword AS must appear before the alias. If an alias is notspecified, the data source name is used as the name of the Pass-Throughconnection.

Page 190: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

182 CONNECT Statement � Chapter 13

connect-statement-argumentsspecifies arguments that indicate whether you can make multiple connections,shared or unique connections, and so on, to the database. Some of theseconnect-statement-arguments are optional.

database-connection-argumentsspecifies the data source-specific arguments that are needed by PROC SQL toconnect to the data source. These arguments are not required and the defaultbehavior opens a dialog box that prompts you for information they provide.

Database Connection ArgumentsThe arguments that are listed below are available with the Pass-Through Facility forPC files. These arguments provide information to the Pass-Through Facility to connectto the PC files or to the database. These options are used when connecting to PC FilesServer.

DSN=data-source-namespecifies the ODBC data source name that is used to access the PC data throughan ODBC driver on the PC.

Note: This ODBC data source must be defined on the PC where the PC FilesServer is currently running. �

CONNECT_STRING=connection-stringspecifies connection options for your data source or database. Separate multipleoptions with a semicolon. This is an advanced connection method that you shoulduse only when you know the exact syntax of all connection options that the ODBCdriver requires for a successful connection.

PATH=path-for-filespecifies the data source file location for the Microsoft Access database file orMicrosoft Excel workbook file.

PORT=port-numberThe port or service name on the PC that the SAS PC Files Server is listening on.This port or service name is displayed on the SAS PC Files Server window when itis started on the PC. This is a required field when connecting to the PC FilesServer for data.Alias: SERVICE|SERVICE_NAME

SERVER=pc-server-host-namespecifies the computer name of the PC on which you started the PC Files Server.This name is required by UNIX users to connect to this server machine and isreflected on the server control panel. This is a required field when connecting tothe PC Files Server for data.

You can specify this host name as a simple computer name (for example,wxp320), a fully qualified network name (for example, wxp320.domain.com), or anIP address.

SERVERUSER=’domain\server-user-name’specifies the domain name and User ID for the PC running PC Files Server.Always enclose the value in quotes, otherwise the backslash can be misinterpretedby the SAS parser.Alias: SERVERUIDNote: If you are not on a domain, omit the domain name and the backslash.Note: Use the USER= option for database User IDs.

SERVERPASS=’server-user-password’

Page 191: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � CONNECT Statement 183

specifies the password for the PC Files Server for the User ID given. If the accounthas no password, omit this option. Always enclose the value in quotes in order topreserve the case of the password.

Alias: SERVERPASSWORD|SERVERPW|SERVERPWD

Note: Passwords are generally case sensitive.

Note: Use the PASSWORD= option for database passwords.

SSPI=YES|NOenables the PC Files Server to allow Integrated Windows Authentication. This is amechanism for the Windows client and server to exchange credentials.

Default: NO

Note: SSPI can also be enabled by specifying the –SSPI option on the SAScommand line.

Restriction: Microsoft Windows 64-Bit only.

DBPASSWORD=database-file-passwordenables you to access your file if you have database-level security set in your MDBfile. A database password is case sensitive, and you can define it instead ofuser-level security

Note: Microsoft Access only.

DBSYSFILE=workgroup-information-filecontains information about the users in a workgroup based on information thatyou define for your Microsoft Access database. Any user and group accounts orpasswords you create are saved in the new workgroup information file.

PASSWORD=user-passwordspecifies a password for the user account, if required by the data source.Passwords are case sensitive.

MSENGINE= ACE|JETdetermines the database engine used for accessing the Microsoft Excel file orMicrosoft Access database. The Microsoft Jet engine is older and supports formatsup to 2003. The Microsoft Ace engine supports 2007 and older formats.

Restriction: It is recommended that you do not use this file option unless youare trying to create a 95 format file.

Default: ACE

USER=User IDspecifies a default user account name. The default value is Admin. User namescan be 1 to 20 characters long and can include alphabetic characters, accentedcharacters, numbers, and spaces. If you have user-level security set in your MDBfile, you need to use this option and the PASSWORD= option to access your file.

VERSION=2007 | 2003 | 2002 | 2000 | 97 | 95 | 5sets the version of Microsoft Excel workbook. The default value is 97.

Alias: VER

Note: You do not need to specify this option for an existing Microsoft Excel file.However, if you want to create a new Microsoft Excel workbook file, you can usethis option to specify the version that you want to create. Note that versions 97,2000, and 2003 share the same file format. Versions 95 and 5 share a separatefile format.

Restriction: Microsoft Excel only.

Page 192: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

184 CONNECT Statement � Chapter 13

CONNECT Statement ArgumentsThe arguments that are listed below are available with the Pass-Through FacilityCONNECT statement for PC Files. These arguments extend some of the LIBNAMEstatement connection management features to the Pass-Through Facility.

AUTOCOMMIT=YES | NOdetermines whether the ACCESS engine commits (saves) updates as soon as theuser submits them.

YESspecifies that updates are committed (saved) to the table as soon as they aresubmitted. No rollback is possible.

NOspecifies that the SAS/ACCESS engine automatically performs the commitwhen it reaches the end of the file.

Default: YES

Note: The default value for this option is different from the LIBNAMEoption. �

COMMAND_TIMEOUT=number-of-secondsspecifies the number of seconds that pass before a data source command times out.Default: 0 (no time-out)Alias: TIMEOUT=

CONNECTION= SHARED |GLOBALspecifies whether multiple CONNECT statements for a data source can use thesame connection. The CONNECTION= option enables you to control the numberof connections, and therefore transactions, that your SAS/ACCESS engine executesand supports for each CONNECT statement.

SHAREDspecifies that the CONNECT statement makes one connection to the DBMS.Only Pass-Through statements that use this alias share the connection.

GLOBALspecifies that multiple CONNECT statements can share the same connectionto the DBMS if they use identical values for CONNECTION=,CONNECTION_GROUP=, and any database connection arguments.

Default: SHARED

CONNECTION_GROUP= connection-groupcauses operations against multiple librefs to share a connection to the data source.Also causes operations against multiple Pass-Through Facility CONNECTstatements to share a connection to the data source.

CURSOR_TYPE= DYNAMIC | FORWARD_ONLY | KEYSET_DRIVEN | STATICspecifies the cursor type for read-only cursors and for cursors to be updated.

DYNAMICspecifies that the cursor reflects all changes that are made to the rows in aresult set as you move the cursor. The data values and the membership ofrows in the cursor can change dynamically on each fetch. This is the defaultfor the DB2 UNIX, PC files, and Microsoft SQL Server interfaces.

FORWARD_ONLY

Page 193: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � CONNECT Statement 185

specifies that the cursor behaves like a DYNAMIC cursor, except that itsupports only fetching the rows sequentially.

KEYSET_DRIVENspecifies that the cursor determines which rows belong to the result set whenthe cursor is opened. However, changes that are made to these rows arereflected as you scroll around the cursor.

STATICspecifies that the complete result set is built when the cursor is opened. Nochanges that are made to the rows in the result set after the cursor is openedare reflected in the cursor. Static cursors are read-only.

Default: NoneAlias: CURSOR=

DBGEN_NAME=DBMS | SASspecifies that the data source columns are renamed, and specifies the format thatthe new names follow.

DBMSspecifies that the data source columns are renamed to valid SAS variablenames. Disallowed characters are converted to underscores. If a column isconverted to a name that already exists, then a sequence number is appendedto the end of the new name.

SASspecifies that data source columns are renamed to the format _COLn, wheren is the column number (starting with zero).

Default: DBMS

DBMAX_TEXT=nspecifies an integer between 1 and 32,767 that indicates the maximum length for acharacter string. Longer character strings are truncated. This option applies onlywhen you are reading, appending, and updating Microsoft Access or Excelcharacter data from SAS.

Note: Although you can specify a value less than 256, it is not recommended. �Default: 1,024

DEFER=NO | YESenables you to specify when the CONNECT statement occurs.

NOspecifies that the connection to the data source occurs when the libref isassigned by a LIBNAME statement.

YESspecifies that the connection to the data source occurs when a table in thedata source is opened.

Default: NO

READBUFF=number-of-rowsspecifies the number of rows to use when you are reading data from a data source.Setting a higher value for this option reduces I/O and increases performance, butalso increases memory usage. Additionally, if too many rows are read at once,values returned to SAS might be out of date.Default: 1Alias: ROWSET=

ROWSET_SIZE=

Page 194: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

186 DISCONNECT Statement � Chapter 13

STRINGDATES=YES | NOspecifies whether datetime values are read from the data source as characterstrings or as numeric date values. STRINGDATES= is not available as a data setoption.

YESspecifies that SAS/ACCESS reads datetime values as character strings.

NOspecifies that SAS/ACCESS reads datetimes values as numeric date values.

Default: NOAlias: STRDATES

DetailsThe CONNECT statement establishes a connection with the data source. You establisha connection to send data source-specific SQL statements to the data source or toretrieve data source data. The connection remains in effect until you issue aDISCONNECT statement or terminate the SQL procedure.

To connect to a data source using the Pass-Through Facility, complete the followingsteps:

1 Initiate a PROC SQL step.2 Use the Pass-Through Facility CONNECT statement with the PC files engine

name and then assign an alias if you want.3 Specify any arguments needed to connect to the database.4 Specify any attributes for the connection.

The CONNECT statement is optional for some data sources. However, if you do notspecify it, default values for all database connection arguments are used.

Any return code or message that is generated by the data source is available in themacro variables SQLXRC and SQLXMSG after the statement executes. See “ReturnCodes” on page 112 for more information about these macro variables.

ExampleThe following example uses the CONNECT statement with the PATH= option toconnect to the Microsoft Access database file, c:\demo.mdb:

PROC sql;connect to pcfiles as db (server=d2323 path="c:\demo.mdb");

DISCONNECT Statement

Terminates the connection to the data source.

Valid in: PROC SQL steps (when accessing PC files data using SAS/ACCESS software)

SyntaxDISCONNECT FROM PCFILES | alias

Page 195: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � EXECUTE Statement 187

Argumentsalias

specifies an alias for the connection that was defined in the CONNECT statement.

DetailsThe DISCONNECT statement ends the connection with the data source. If theDISCONNECT statement is omitted, an implicit DISCONNECT is performed whenPROC SQL terminates. The SQL procedure continues to execute until you submit aQUIT statement, another SAS procedure, or a DATA step.

Any return code or message that is generated by the data source is available in themacro variables SQLXRC and SQLXMSG after the statement executes. See “ReturnCodes” on page 112 for more information about these macro variables.

Example

After connection and SQL processing, this example uses the DISCONNECTstatement to disconnect the connection from the database and the QUIT statement toquit the SQL procedure:

disconnect from pcfiles;quit;

EXECUTE Statement

Sends data source-specific, nonquery SQL statements to the data source.

Valid in: PROC SQL steps

SyntaxEXECUTE (data-source-specific-SQL-statement) BY PCFILES | alias;

Arguments(data-source-specific-SQL-statement)

a dynamic nonquery, data source-specific SQL statement. This argument isrequired and must be enclosed in parentheses. However, the SQL statementcannot contain a semicolon because a semicolon represents the end of a statementin SAS. Depending on your data source, the SQL statement can be case-sensitive.It is passed to the data source exactly as you type it.

Any return code or message that is generated by the data source is available inthe macro variables SQLXRC and SQLXMSG after the statement executes. See“Return Codes” on page 112 for more information about these macro variables.

aliasspecifies an alias for the connection that was defined in the CONNECT statement.(You cannot use an alias if the CONNECT statement is omitted.)

Page 196: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

188 CONNECTION TO Component � Chapter 13

DetailsThe EXECUTE statement sends dynamic nonquery, data source-specific SQLstatements to the data source and processes those statements.

The EXECUTE statement cannot be stored as part of a Pass-Through Facility queryin a PROC SQL view.

Useful Statements to Include in EXECUTE StatementsYou can pass the following statements to the data source by using the Pass-ThroughFacility’s EXECUTE statement.

CREATEcreates a data source table, view, index, or other data source object, depending onhow the statement is specified.

DELETEdeletes rows from a data source table.

DROPdeletes a data source table, view, or other data source object, depending on howthe statement is specified.

GRANTgives users the authority to access or modify objects such as tables or views.

INSERTadds rows to a data source table.

REVOKErevokes the access or modification privileges that were given to users by theGRANT statement.

UPDATEmodifies the data in the specified columns of a row in a data source table.

For more information about these and other SQL statements, see the SQLdocumentation for your data source.

ExampleThe following example, after the connection, uses the EXECUTE statement to drop atable, create a table, and insert a row of data:

execute(drop table ‘ My Invoice ‘ ) by pcfiles;execute(create table ‘ My Invoice ‘ (‘ Invoice Number ‘ LONG not null,‘ Billed To ‘ VARCHAR(20),‘ Amount ‘ CURRENCY,‘ BILLED ON ‘ DATETIME)) by pcfiles;execute(insert into ‘ My Invoice ‘

values( 12345, ’John Doe’, 123.45, #11/22/2003#)) by pcfiles;

CONNECTION TO Component

Retrieves and uses data source data in a PROC SQL query or view.

Page 197: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � CONNECTION TO Component 189

Valid in: PROC SQL step SELECT statements

SyntaxCONNECTION TO PCFILES <AS alias> <(database-connection-options)>

Argumentsalias

specifies an alias if one was defined in the CONNECT statement.

database-connection-argumentsspecifies the data source-specific arguments that are needed by PROC SQL toconnect to the data source. These arguments are not required and the defaultbehavior opens a dialog box.

DetailsThe CONNECTION TO component specifies the data source connection that you wantto use or that you want to create (if you have omitted the CONNECT statement).CONNECTION TO then enables you to retrieve data source data directly through aPROC SQL query.

You use the CONNECTION TO component in the FROM clause of a PROC SQLSELECT statement:

SELECT column-list

FROM CONNECTION TO data source-name (data source-query);

CONNECTION TO can be used in any FROM clause, including those in nestedqueries (that is, in subqueries).

You can store a Pass-Through Facility query in a PROC SQL view and then use thatview in SAS programs. When you create a PROC SQL view, any options that youspecify in the corresponding CONNECT statement are also stored. So when the PROCSQL view is used in a SAS program, SAS can establish the appropriate connection tothe data source.

Because external data sources and SAS have different naming conventions, somedata source column names might be changed when you retrieve data source datathrough the CONNECTION TO component.

Examples1 Query Tables or Subtables

After the connection, this example uses the CONNECTION TO component toquery a table or a subtable:

select * from connection to pcfiles (select * from ‘my invoice‘);select * from connection to pcfiles(select ‘Invoice Number‘, Amount from ‘my invoice‘);

2 Create a SAS Data Set from a Microsoft Access Table

This example creates a SAS data set called Newtable from a Microsoft Accesstable:

Page 198: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

190 Special PC Files Queries � Chapter 13

PROC sql;connect to pcfiles (server=d2323 port=8621

path="c:\temp\household.inventory.mdb");create table newtable as select * from;connect to pcfiles (select * from rooms);disconnect from pcfiles;quit;

3 Query a Table Range in an Excel WorkbookThis example connects to an Excel file and queries the INVOICE table (range)

within the Excel workbook:

PROC sql dquote=ansi;connect to pcfiles (path="c:\sasdemo\sasdemo.xls" server=d2323 port=8621);select * from connection to pcfiles

(select * from invoice);disconnect from pcfiles;quit;

4 Use PC Files Server to Create a SAS Data SetThis example uses a PC Files Server through ODBC to create a SAS data set

called Work from a list of tables in a Microsoft SQL Server database:

PROC sql dquote=ansi;connect to pcfiles (server=d2323 port=8621 dsn=mqis user=scott pwd=tiger);create table work as select * from connection to pcfiles (PCFILES::SQLTABLES);disconnect from pcfiles;quit;

Special PC Files QueriesSAS/ACCESS Interface to PC Files on UNIX supports the following special queries.

Many databases provide or use system tables that allow queries to return the list ofavailable tables, columns, procedures, and other useful information. In PC files, muchof this functionality is provided through special APIs (application programminginterfaces) in order to accommodate databases that do not follow the SQL tablestructure. You can use these special queries on non-SQL and SQL databases. Here isthe general format of the special queries:

PCFILES::SQLAPI “parameter 1”,”parameter n”

PCFILES::is required to distinguish special queries from regular queries.

SQLAPIis the specific API that is being called. Both PCFILES:: and SQLAPI are casesensitive.

"parameter n"is a quoted string that is delimited by commas.

Within the quoted string, two characters are universally recognized: the percent sign(%) and the underscore (_). The percent sign matches any sequence of zero or morecharacters; the underscore represents any single character. Each driver also has anescape character that can be used to place characters within the string. Consult thedriver’s documentation to determine the valid escape character.

Page 199: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Pass-Through Facility: PC Files on Linux, UNIX, and 64-Bit Microsoft Windows � Special PC Files Queries 191

The values for the special query arguments are DBMS specific. For example, yousupply the fully qualified table name for a “Catalog” argument. In dBASE, the value of“Catalog” might be c:\dbase\tst.dbf and in SQL Server, the value might betest.customer. In addition, depending on the DBMS that you are using, valid valuesfor “Schema” argument might be a user ID, a database name, or a library. Allarguments are optional. If you specify some but not all arguments within a parameter,use a comma to indicate the omitted parameters. If you do not specify any parameters,commas are not necessary.

Note: These special queries might not be available for all PCFILES drivers. �

The following special queries are supported:

PCFILES::SQLTables <"Catalog", "Schema", "Table-name", "Type">returns a list of all tables that match the specified arguments. If no arguments arespecified, all accessible table names and information are returned.

PCFILES::SQLColumns <"Catalog", "Schema", "Table-name", "Column-name">returns a list of all columns that match the specified arguments. If no argumentsare specified, all accessible column names and information are returned.

PCFILES::SQLColumnPrivileges <"Catalog", "Schema", "Table-name","Column-name">

returns a list of all column privileges that match the specified arguments. If noarguments are specified, all accessible column names and privilege information arereturned.

PCFILES::SQLForeignKeys <"PK-catalog", "PK-schema", "PK-table-name","FK-catalog", "FKschema", "FKtable-name">

returns a list of all columns that comprise foreign keys that match the specifiedarguments. If no arguments are specified, all accessible foreign key columns andinformation are returned.

PCFILES::SQLPrimaryKeys <"Catalog", "Schema", "Table-name">returns a list of all columns that compose the primary key that matches thespecified table. A primary key can be composed of one or more columns. If no tablename is specified, this special query fails.

PCFILES::SQLProcedureColumns <"Catalog", "Schema", "procedure-name","Column-name">

returns a list of all procedure columns that match the specified arguments. If noarguments are specified, all accessible procedure columns are returned.

PCFILES::SQLProcedures <"Catalog", "Schema", "procedure-name">returns a list of all procedures that match the specified arguments. If noarguments are specified, all accessible procedures are returned.

PCFILES::SQLSpecialColumns <"Identifier-type", "Catalog-name", "Schema-name","Table-name", "Scope", "Nullable">

returns a list of the optimal set of columns that uniquely identify a row in thespecified table.

PCFILES::SQLStatistics <"Catalog", "Schema", "Table-name">returns a list of the statistics for the specified table name, with options ofSQL_INDEX_ALL and SQL_ENSURE set in the SQLStatistics API call. If thetable name argument is not specified, this special query fails.

PCFILES::SQLTablePrivileges <"Catalog", "Schema", "Table-name">returns a list of all tables and associated privileges that match the specifiedarguments. If no arguments are specified, all accessible table names andassociated privileges are returned.

Page 200: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

192 Special PC Files Queries � Chapter 13

PCFILES::SQLGetTypeInforeturns information about the data types that are supported in the data source.

Page 201: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

193

P A R T5

ACCESS and DBLOAD Procedures

Chapter 14. . . . . . . . .The ACCESS Procedure for PC Files 195

Chapter 15. . . . . . . . .The DBLOAD Procedure 219

Chapter 16. . . . . . . . .File-Specific Reference for the ACCESS and DBLOADProcedures 229

Page 202: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

194

Page 203: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

195

C H A P T E R

14The ACCESS Procedure for PCFiles

Overview: ACCESS Procedure for PC Files 195Using ACCESS Procedure Statements 196

SAS/ACCESS Descriptors for PC Files 197

Overview 197

Access Descriptors 197

View Descriptors 197SAS Passwords for Descriptors 197

Performance and Efficient View Descriptors for PC Files 198

General Guidelines 198

Extracting Data Using a View 198

ACCESS Procedure Syntax 198

PROC ACCESS Statement 199ASSIGN Statement 200

CREATE Statement 201

DROP Statement 204

FORMAT Statement 205

LIST Statement 206MIXED Statement 207

PATH= Statement 208

QUIT Statement 208

RENAME Statement 209

RESET Statement 210SELECT Statement 212

SUBSET Statement 213

TYPE Statement 213

UNIQUE Statement 214

UPDATE Statement 215

Overview: ACCESS Procedure for PC FilesThe ACCESS procedure for PC files is available only under Windows operating

environments. You can use the ACCESS procedure with DBF, DIF, WK1, WK3, WK4,Excel 4, Excel 5, and Excel 95 file formats.You can use the ACCESS procedure to create access descriptors, view descriptors, andSAS data files. Descriptor files describe PC files data so that you can directly read,update, or extract PC files data while working within a SAS program. See “SAS/ACCESS Descriptors for PC Files” on page 197 for more information.

Page 204: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

196 Using ACCESS Procedure Statements � Chapter 14

CAUTION:Altering a PC file might invalidate defined descriptors. Altering the format of a PC filethat has descriptor files defined on it might cause these descriptors to be out-of-dateor invalid. For example, if you add a column to a file and an existing accessdescriptor is defined on that file, the access descriptor and any view descriptors basedon it do not show the new column. You must recreate the descriptors to be able toshow and select the new column. �

The descriptor files are compatible with SAS 6. The view descriptor saves a columnname with up to eight characters in uppercase. Any column name longer than eightcharacters is truncated. When duplicate names occur after truncation, a unique nameis generated with a number appended to it. However, the view descriptor also saves fullcolumn names as is in the label fields. Full column names can be read from variablelabels.

Using ACCESS Procedure StatementsThe following table presents a task-oriented overview of the statements you use

inside a PROC ACCESS program block to create or modify access and view descriptors.See “ACCESS Procedure Syntax” on page 198 for the complete syntax for this procedure.

Table 14.1 Options and Statements Required for the ACCESS Procedure

Task Options and Statements That You Use

create an access descriptor PROC ACCESS DBMS=DBF|DIF|WKn|XLS;CREATE libref.member-name.ACCESS;

required-database-description-statements;optional-editing-statements;

RUN;

create an access descriptor anda view descriptor

PROC ACCESS DBMS=DBF|DIF|WKn| XLS;CREATE libref.member-name.ACCESS;

required-database-description-statements;optional-editing-statements;

CREATE libref.member-name.VIEW;SELECT column-list;

optional-editing-statements;

RUN;

create a view descriptor from anexisting access descriptor

PROC ACCESS DBMS=DBF|DIF|WKn|XLSACCDESC=libref.access-descriptor;

CREATE libref.member-name.VIEW;SELECT column-list;

optional-editing-statements;

RUN;

As the table indicates, you can create one or more access descriptors and viewdescriptors in one execution of PROC ACCESS, or you can create the descriptors in

Page 205: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � SAS Passwords for Descriptors 197

separate executions. See “CREATE Statement” on page 201 for additional informationabout statement order.

SAS/ACCESS Descriptors for PC Files

OverviewSAS/ACCESS descriptor files are the tools that the ACCESS procedure uses to

establish a connection to a PC file. To create descriptor files, use the ACCESSprocedure. There are two types of descriptor files: access descriptors and viewdescriptors. The next sections provide an overview of these files.

Access DescriptorsAn access descriptor holds essential information about the structure of the PC file

that you want to access. For example, you can access the file’s format and name, itsdatabase field or column names, and its data types. Access descriptors can also containthe corresponding SAS information such as the SAS variable names and formats.Typically, you have only one access descriptor for each PC file.

An access descriptor describes only a PC file format and contents to SAS, that is, it isa master description file of the PC file for SAS. You cannot use an access descriptor in aSAS program. Instead, you use an access descriptor to create other SAS files, calledview descriptors, that you use in SAS programs.

View DescriptorsA view descriptor defines some or all of the data that is described by one access

descriptor (and, therefore, one PC file). For example, you might want to use only threeof nine possible database columns and only some of the rows in a PC file. The viewdescriptor enables you to do this by selecting the database fields or columns that youwant to use and specifying criteria to retrieve only the rows you want. Typically, youcreate several view descriptors based on one access descriptor, where each viewdescriptor selects a different subset of the PC files data.

A view descriptor is a SAS data set or, more specifically, a SAS data view. You use aview descriptor in a SAS program much as you would any SAS data set. For example,you can specify a view descriptor in the DATA= statement of a SAS procedure or theSET statement of a DATA step. You can use a view descriptor in a SELECT statementof the SQL procedure to join view descriptor data with SAS data, for example.

You can use a view descriptor to update data directly in some of the PC file formats,such as the DBF file format.

In some cases, you might also want to create a SAS data file from data stored in aPC file. Using a view descriptor to copy PC files data into a SAS data file is calledextracting the data.

SAS Passwords for DescriptorsSAS enables you to control access to SAS data sets and access descriptors by

associating one or more SAS passwords with them.

Page 206: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

198 Performance and Efficient View Descriptors for PC Files � Chapter 14

Table 14.2 Password and Descriptor Interaction

READ= WRITE= ALTER=

access descriptor no effect on descriptor no effect on descriptor protects descriptor frombeing read or updated

view descriptor protects PC file data frombeing read or updated

protects PC file data frombeing updated

protects descriptor frombeing read or updated

In this example, the PROC DATASETS statement assigns the passwords MYPW andMYDEPT with READ and ALTER levels of protection to the view descriptorVLib.JobC204:

PROC datasets library=vlib memtype=view;modify jobc204 (read=mypw alter=mydept);

run;

For detailed information about the levels of protection and the types of passwordsyou can use, refer to your Base SAS software documentation.

Performance and Efficient View Descriptors for PC Files

General GuidelinesWhen you create and use view descriptors, follow these guidelines to minimize the

use of SAS resources and to reduce the time it takes to access data:� Select only the columns your SAS program needs. Selecting unnecessary columns

adds extra processing time.� Where possible, specify selection criteria to subset the number of observations

processed by SAS.� To present PC files data in sorted order, reference a view descriptor in a PROC SQL

query. Otherwise, you might need to extract the data to sort it, as described below.

Extracting Data Using a ViewIn some cases, it might be more efficient to use a view descriptor to extract PC files

data and place it in a SAS data file instead of using the view descriptor to read the datadirectly.

A PC file is read every time a view descriptor is referred to in a SAS program andthe program is executed. It is better to extract data under these circumstances:

� Extract PC files data if the file is large and you use the data repeatedly in SASprograms.

� Extract PC files data if you use sorted data several times in a SAS program.� Extract PC files data for added security, you can assign a password to the

extracted SAS data file.

ACCESS Procedure SyntaxThe general syntax for the ACCESS procedure is presented here. For specific details,

see Chapter 6, “File Format-Specific Reference for the IMPORT and EXPORTProcedures,” on page 25.

Page 207: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � PROC ACCESS Statement 199

PROC ACCESS options;

Create and Update StatementsCREATE libref.member-name.ACCESS|VIEW ;

UPDATE libref.member-name.ACCESS|VIEW ;

Database Description StatementPATH= ’path-and-filename<.PC-filename-extension>’ | <’>filename<’> | fileref;(See your file format-specific chapter for additional database-description statements.)

Editing StatementsASSIGN <=>YES|NO|Y|N;DROP <’>column-identifier-1<’>

<<’>…column-identifier-n <’>>;FORMAT <’>column-identifier-1<’><=>SAS-format-name-1<’>

<…<’>column-identifier-n<’><=>SAS-format-name-n>;LIST <ALL|VIEW|<’>column-identifier <’>>;MIXED <=> YES | NO | Y | N;(The MIXED statement is not available for DIF and DBF files.)QUIT;RENAME <’>column-identifier-1<’><=>SAS-variable-name-1

<…<’>column-identifier-n<’><=>SAS-variable-name-n>;RESET ALL | <’>column-identifier-1 <’><…<’>column-identifier-n<’>>;SELECT ALL|<’>column-identifier-1<’>

<…<’>column-identifier-n <’>>;SUBSET selection-criteria;TYPE <’>column-identifier-1<’><=> C | N

<…column-identifier-n <=> C | N>;(The TYPE statement is not available for DBF files.)UNIQUE <=>YES|NO|Y|N ;

RUN;

PROC ACCESS StatementRequirement: This statement is required.Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 files underWindows operating environments

PROC ACCESS options;

OptionsThe PROC ACCESS statement options that are available with all supported PC file

formats are described below. Other options, specific to particular PC file formats, aredescribed in the file format specific chapter.

Page 208: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

200 ASSIGN Statement � Chapter 14

DBMS=pc-file-formatspecifies which PC database product or spreadsheet system you want to accessfrom SAS. This is the only required option. The valid types are DBF, DIF, WK1,WK3, WK4, and XLS.

ACCDESC=libref.access-descriptor <(READ|WRITE|ALTER=password)>specifies an existing access descriptor.

Use this option when creating or updating a view descriptor based on an accessdescriptor that was created in a separate PROC ACCESS step.

You name the view descriptor in the CREATE statement. You can also use aSAS data set option on the ACCDESC= option to specify a SAS password for theaccess descriptor.

The ACCDESC= option has two aliases: AD= and ACCESS=.

VIEWDESC=libref.view-descriptorspecifies a view descriptor as input for the OUT= option. (See the description ofOUT=.)

OUT= <libref.>member-namespecifies a SAS data file. When VIEWDESC= and OUT= are used together, youcan write data that is accessed from the view descriptor to the SAS data set that isspecified in OUT=. Here is an example:

PROC access viewdesc=vlib.invq4out=dlib.invq4;

run;

ASSIGN Statement

Indicates whether SAS variable names and formats are automatically generated.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor

Interacts with: FORMAT, RENAME, RESET, UNIQUENot allowed with: UPDATE

Default: NOAlias: AN

ASSIGN <=> YES|NO|Y|N;

DetailsThe ASSIGN statement indicates whether SAS variable names and formats are

automatically generated. Where long names must be shortened to the SAS length limitof eight characters, variable names are automatically generated.

An editing statement such as ASSIGN appears after the CREATE anddatabase-description statements. See “CREATE Statement” on page 201 for moreinformation.

Page 209: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � CREATE Statement 201

You can use the value NO (or N) to modify SAS variable names and formats whenyou create an access descriptor and when you create view descriptors that are based onthis access descriptor. During an access descriptor’s creation, you use the RENAMEstatement to change SAS variable names, and you use the FORMAT statement tochange SAS formats.

Specify a YES (or Y) value for this statement to generate unique SAS variable namesfrom the first eight characters of the PC file column names, according to the rules listedbelow. With YES, you can change the SAS variable names only in the access descriptor.The SAS variable names that are saved in an access descriptor are always used whenview descriptors are created from the access descriptor; you cannot change them in theview descriptors.

Default SAS variable names are generated according to these rules:� If the column name is longer than eight characters, SAS uses only the first eight

characters. If truncating results in duplicate names, numbers are appended to theends of the names to prevent duplicate names. For example, the names clientsname and clientsnumber become the SAS names clientsn and clients0.

� If the column name in the PC file contains blank characters, SAS ignores theblank characters. For example, the column name Paid On becomes the SAS namePaidOn.

� If the column name in the PC file starts with a digit (0 through 9), SAS adds thecharacter Z before it. For example, the column name 1stYear becomes the SASname Z1stYear.

� If the column name contains characters that are invalid in SAS names (includingnational characters), SAS replaces the invalid characters with underscores (_). Forexample, the column name $Paid becomes the SAS variable name _Paid.

When the SAS/ACCESS interface encounters the next CREATE statement to createan access descriptor, the ASSIGN statement is reset to the default NO value.

CREATE Statement

Creates a SAS/ACCESS descriptor file.

Requirement: This statement is required.Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptor

CREATE libref.descriptor-name.ACCESS|VIEW;

DetailsUse CREATE to create an access or view descriptor for a PC file you want to access

from SAS. To access a particular PC file of a supported type, you must create first anaccess descriptor, and then one or more view descriptors based on the access descriptor.

The descriptor name has three parts, separated by periods. The libref identifies aSAS library, which is associated with a directory on the local system disk where thedescriptor is created. The libref must already have been created using the LIBNAME

Page 210: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

202 CREATE Statement � Chapter 14

statement. The descriptor-name is the name of the descriptor to be created. The thirdpart is the descriptor type. Specify ACCESS for an access descriptor or VIEW for a viewdescriptor.

You can use the CREATE statement as many times as necessary in one procedureexecution. That is, you can create multiple access descriptors, as well as one or moreview descriptors based on these access descriptors, within the same execution of theACCESS procedure. Or, you can create access descriptors and view descriptors inseparate executions of the procedure.

You can use the CREATE and the UPDATE in the same PROC ACCESS block withone restriction: a CREATE statement for a view descriptor should not follow anUPDATE statement.

Creating Access DescriptorsWhen you create an access descriptor, you must place statements or groups of

statements in a certain order after the PROC ACCESS statement and its options, aslisted here:

1 CREATE must be the first statement after the PROC ACCESS statement with oneexception: if the block includes both the CREATE and the PDATE statements,either statement can be the first in the block.

2 Specify any database-description statement, such as PATH=. This informationdescribes the location and characteristics of the PC file. These statements must beplaced before any editing statements. Do not specify these statements when youcreate view descriptors.

Information from database-description statements is stored in an accessdescriptor. Therefore, you do not repeat this information when you create viewdescriptors.

3 Specify any editing statements: ASSIGN, DROP, FORMAT, LIST, RENAME,RESET, and SUBSET. QUIT is also an editing statement, but using it terminatesPROC ACCESS without creating your descriptor.

4 Specify the RUN statement. RUN executes the ACCESS procedure.

The order of the statements within the database-description and editing groupssometimes matters; see the individual statement descriptions for more information.

Note: Altering a PC file that has descriptor files defined on it might cause thedescriptor files to be out-of-date or invalid. For example, if you recreate a file and add anew column to the file, an existing access descriptor defined on that file does not showthat column, but the descriptor can still be valid. However, if you recreate a file anddelete an existing column from the file, the descriptor might be invalid. If the deletedcolumn is included in a view descriptor and this view is used in a SAS program, theprogram fails and an error message is written to the SAS log. �

Creating View DescriptorsYou can create view descriptors and access descriptors in the same ACCESS

procedure or in separate procedures.To create a view descriptor and the access descriptor on which it is based within the

same PROC ACCESS execution, you must place the statements or groups of statementsin a particular order after the PROC ACCESS statement and its options, as listed below:

1 Create the access descriptor as described in “Creating Access Descriptors” on page202, except omit the RUN statement.

2 Specify the CREATE statement for the view descriptor. The CREATE statementmust follow the PROC ACCESS statements that you used to create the accessdescriptor.

Page 211: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � CREATE Statement 203

3 Specify any editing statements: SELECT, SUBSET, and UNIQUE are valid onlywhen creating view descriptors. FORMAT, LIST, RENAME, and RESET are validfor both view and access descriptors. You can specify FORMAT, RENAME, andUNIQUE only when you specify ASSIGN=NO in the access descriptor that thisview descriptor references. QUIT is also an editing statement. However, if you useit, it terminates PROC ACCESS without creating your descriptor.

Statement order within this group usually does not matter. See the individualstatement descriptions for any restrictions.

4 Specify the RUN statement. RUN executes PROC ACCESS.

To create a view descriptor based on an access descriptor that was created in aseparate PROC ACCESS step, specify the access descriptor’s name in the ACCDESC=option in the new PROC ACCESS statement. You must specify the CREATE statementbefore any of the editing statements for the view descriptor.

If you create only one descriptor in a PROC step, the CREATE statement and itsaccompanying statements are checked for errors when you submit PROC ACCESS forprocessing. If you create multiple descriptors in the same PROC step, each CREATEstatement (and its accompanying statements) is checked for errors as it is processed.

If no errors are found when the RUN statement is processed, all descriptors aresaved. If errors are found, error messages are written to the SAS log, and processing isterminated. After you correct the errors, resubmit your statements.

Examples

Example 1: Create an Access Descriptor for a Worksheet FileThis example creates the access descriptor AdLib.Product for the worksheet file namedc:\sasdemo\specprod.wk4:

LIBNAME adlib ’c:\sasdata’;

PROC access dbms=wk4;create adlib.product.access;path=’c:\sasdemo\specprod.wk4’;getnames=yes;assign=yes;rename productid prodid

fibername fiber;format productid 4.

weight e16.9fibersize e20.13width e16.9;

run;

Example 2: Create an Access Descriptor for an Excel WorksheetThis example creates an access descriptor named AdLib.Employ for the Excelworksheet named c:\dubois\employ.xls. It also creates a view descriptor namedVLib.Emp1204 for this same file:

LIBNAME adlib ’c:\sasdata’;LIBNAME vlib ’c:\sasviews’;

PROC access dbms=xls;/* create access descriptor */create adlib.employ.access;

Page 212: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

204 DROP Statement � Chapter 14

path=’c:\dubois\employ.xls’;getnames=yes;assign=no;list all;

create vlib.emp1204.view;/* create view descriptor */select empid lastname hiredate salary

dept gender birthdate;format empid 6.

salary dollar12.2jobcode 5.hiredate datetime7.birthdate datetime7.;

subset where jobcode=1204;run;

Example 3: Create a View Descriptor from an Access DescriptorThis example creates a view descriptor VLib.BDays from the AdLib.Employ accessdescriptor, which was created in the previous PROC ACCESS step. You could also useFORMAT because the access descriptor was created with ASSIGN=NO.

LIBNAME adlib ’c:\sasdata’;LIBNAME vlib ’c:\sasviews’;

PROC access accdesc=adlib.employ;create vlib.bdays.view;select empid lastname birthdate;format empid 6.

birthdate datetime7.;run;

DROP Statement

Drops a column from a descriptor.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor, view descriptorInteracts with: RESET, SELECT, UPDATE

DROP <’>column-identifier-1<’><…<’>column-identifier-n<’>>;

Page 213: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � FORMAT Statement 205

DetailsThe DROP statement drops the specified column from an access descriptor. The

column cannot be selected for a view descriptor that is based on the access descriptor.However, the specified column in the PC file remains unaffected by this statement.

You can specify the DROP statement only when you create or update an accessdescriptor or when you update a view descriptor. DROP is not allowed when you createa view descriptor. When you use the UPDATE statement, you can specify DROP toremove a column from the view descriptor. However, the specified column in the PC fileremains unaffected by the DROP statement.

An editing statement, such as DROP, must follow the CREATE anddatabase-description statements when you create an access descriptor. See “CREATEStatement” on page 201 for more information about the order of statements.

The column-identifier argument can be either the column name or the positionalequivalent from the LIST statement, which is the number that represents columnplacement in the access descriptor or view descriptor. For example, to drop the thirdand fifth columns, submit this statement:

drop 3 5;

If the column name contains lowercase characters, special characters, or nationalcharacters, enclose the name in quotation marks. You can drop as many columns as youwant in one DROP statement.

To display a column that was previously dropped, specify that column name in theRESET statement. However, doing so also resets all column attributes—such as theSAS variable name format—to their default values.

FORMAT Statement

Changes a SAS format for a PC file column.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptorInteracts with: ASSIGN, DROP, RESET

FORMAT|FMT <’>column-identifier-1<’><=>SAS format-name-1<…<’>column-identifier-n<’><=>SAS format-name-n>;

DetailsThe FORMAT statement changes a SAS variable format from its default format. The

default SAS variable format is based on the data type and format of the PC file column.(See your PC file’s chapter for information about the default data types and formatsthat SAS assigns to PC files data.)

An editing statement, such as FORMAT, must follow the CREATE statement and thedatabase-description statements when you create a descriptor. See “CREATEStatement” on page 201 for more information about the order of statements.

The column-identifier argument can be either the column name or the positionalequivalent from the LIST statement, which is the number that represents the column’s

Page 214: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

206 LIST Statement � Chapter 14

place in the access descriptor. For example, to associate the DATE9. format with theBIRTHDATE column and with the second column in the access descriptor, submit thisstatement:

format 2=date9. birthdate=date9.;

The column identifier is specified on the left and the SAS format is specified on theright of the expression. The equal sign (=) is optional. If the column name containslowercase characters, special characters, or national characters, enclose the name inquotation marks. You can enter formats for as many columns as you want in oneFORMAT statement.

You can use the FORMAT statement with a view descriptor only if the ASSIGNstatement that was used when creating the access descriptor was specified with the NOvalue.

Note: When you use the FORMAT statement with access descriptors, the FORMATstatement also reselects columns that were previously dropped with the DROPstatement. �

LIST Statement

Lists columns in the descriptor and gives information about them.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptorDefault: ALL

LIST <ALL|VIEW|<’>column-identifier<’>>;

DetailsThe LIST statement lists columns in the descriptor along with information about the

columns. You can use the LIST statement when creating an access descriptor or a viewdescriptor. The LIST information is written to your SAS log.

If you use an editing statement, such as LIST, it must follow the CREATE statementand the database-description statements when you create a descriptor. You can specifyLIST as many times as you want while creating a descriptor; specify LIST last in yourPROC ACCESS code to see the entire descriptor. Or, if you are creating multipledescriptors, specify LIST before the next CREATE statement in order to list allinformation about the descriptor that you are creating.

The LIST statement can take one or more of these arguments:

ALLlists all columns in the PC file, the positional equivalents, the SAS variable names,and the SAS variable formats that are available for the access descriptor. Whenyou are creating an access descriptor, *NON-DISPLAY* appears next to the columndescription for any column that has been dropped. When you are creating a viewdescriptor, *SELECTED* appears next to the column description for columns thatyou have selected for the view.

Page 215: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � MIXED Statement 207

VIEWlists all columns that are selected for the view descriptor, along with theirpositional equivalents, their SAS names and formats, and any subsetting clauses.Any columns that were dropped in the access descriptor are not displayed. TheVIEW argument is valid only for a view descriptor.

column-identifierlists the specified column name, its positional equivalent, its SAS variable nameand format, and whether the column has been selected. If the column namecontains lowercase characters, special characters, or national characters, enclosethe name in quotation marks.

The column-identifier argument can be either the column name or the positionalequivalent, which is the number that represents the column’s place in thedescriptor. For example, to list information about the fifth column in thedescriptor, submit this statement:

list 5;

You can use one or more of these previously described options in a LIST statement,in any order.

MIXED Statement

Determines whether to convert numeric data values in a column to their character representationwhen the corresponding SAS variable is expecting a character value.

Valid: for WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats under Windowsoperating environments

MIXED <=> YES | NO | Y | N;

DetailsYou use the MIXED statement with WKn and XLS files if you have both numeric and

character data in a column. Specifying YES allows both numeric and character data tobe displayed as SAS character data. NO, the default, treats any data in a column thatdoes not match the specified type as missing values.

You can change the default value to YES by setting the SS_MIXED environmentvariable. For more information, see “Setting Environment Variables for XLS Files” onpage 240.

The MIXED statement is an editing statement and must follow the CREATEstatement and any database descriptions when you create an access descriptor.

Page 216: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

208 PATH= Statement � Chapter 14

PATH= Statement

Specifies the path and filename of the file to access.

Requirement: This statement is required.Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, Excel 95 file formats underWindows operating environmentsApplies to: access descriptor

PATH= ’path-and-filename<.PC-file-extension>’ |<’>filename<’> | fileref ;

DetailsThe PATH= statement indicates the path and name of the file you want to access. The

length of the filename and its other conventions can vary with the operating system.See the host documentation for your operating environment for more information.

For compatibility, place the PATH= statement immediately after the CREATEstatement and before any other database-description statements when creating accessdescriptors. See “CREATE Statement” on page 201 for more information.

You can specify the PATH= statement with one of these arguments:

’path-and-filename<.PC-file-extension>’specifies the fully qualified path and filename. You must enclose the entire pathand filename in quotation marks, including the appropriate PC file extension, suchas .dbf, .dif, .wk1, .wk3, wk4, .mdb, or .xls. If you omit the file extension,SAS/ACCESS software supplies it for you.

<’>filename<’>specifies the name of a file. The file must be located in your current (default)directory. If no extension is specified, the SAS/ACCESS interface supplies it foryou. If the filename includes characters that are invalid in SAS names, such asthe dollar sign ($) or if the filename begins with a number, you must enclose theentire filename in quotation marks.

filerefspecifies a fileref that references the path and name of the file. (Assigning a filerefwith the FILENAME statement is described in Step-by-Step Programming withBase SAS Software.)

QUIT Statement

Terminates the procedure.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptorAlias: EXIT

Page 217: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � RENAME Statement 209

QUIT;

DetailsThe QUIT statement terminates the ACCESS procedure without any further

descriptor creation.

RENAME Statement

Modifies the SAS variable name.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptorInteracts with: ASSIGN, RESET

RENAME <’>column-identifier-1<’><=>SAS variable-name-1<…<’>column-identifier-n<’><=>SAS variable-name-n>;

DetailsThe RENAME statement enters or modifies the SAS variable name that is associated

with a column in a PC file. Use the RENAME statement when creating an accessdescriptor or a view descriptor.

An editing statement, such as RENAME, must follow the CREATE statement andthe database-description statements when you create a descriptor. See “CREATEStatement” on page 201 for more information about the order of statements.

Two factors affect the use of the RENAME statement: whether you specify theASSIGN statement when you are creating an access descriptor, and the type ofdescriptor that you are creating.

� If you omit the ASSIGN statement or specify it with a NO value, the renamed SASvariable names that you specify in the access descriptor are retained throughouta SAS/ACCESS procedure execution. For example, if you rename the Customercolumn to CustNum when you create an access descriptor, that column continuesto be named CustNum when you select it in a view descriptor unless a RESETstatement or another RENAME statement is specified.

When creating a view descriptor that is based on this access descriptor, you canspecify the RESET statement or another RENAME statement to rename thevariable again, but the new name applies only in that view. When you create otherview descriptors, the SAS variable names are derived from the access descriptorvariable names.

� If you specify the YES value in the ASSIGN statement, you can use the RENAMEstatement to change SAS variable names only while creating an access descriptor.As described earlier in the ASSIGN statement, SAS variable names, and formatsthat are saved in an access descriptor are always used when creating viewdescriptors that are based on it.

Page 218: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

210 RESET Statement � Chapter 14

The column-identifier argument can be either the PC file column name or thepositional equivalent from the LIST statement, which is the number that represents thecolumn’s place in the descriptor. For example, to rename the SAS variable names thatare associated with the seventh column and the nine-character FIRSTNAME column ina descriptor, submit this statement:

rename 7 birthdy ’firstname’=fname;

The column name (or positional equivalent) is specified on the left side of theexpression, with the SAS variable name on the right side. The equal sign (=) isoptional. If the column name contains lowercase characters, special characters, ornational characters, enclose the name in quotation marks. You can rename as manycolumns as you want in one RENAME statement.

When you are creating a view descriptor, the RENAME statement automaticallyselects the renamed column for the view. That is, if you rename the SAS variableassociated with a column, you do not have to issue a SELECT statement for thatcolumn.

When you are creating an access descriptor, the RENAME statement also reselectscolumns that were previously dropped with the DROP statement.

RESET Statement

Resets PC file columns to their default settings.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environments

Applies to: access descriptor or view descriptor

Interacts with: ASSIGN, DROP, FORMAT, RENAME, SELECT

Not allowed with: UPDATE

RESET ALL|<’>column-identifier-1<’><…<’>column-identifier-n<’>>;

DetailsThe RESET statement resets either the attributes of all columns or the attributes of

the specified columns to their default values. The RESET statement can be used whenyou create an access descriptor or a view descriptor, but it is not allowed when you areupdating a descriptor. RESET has different effects on access and view descriptors, asdescribed below.

If you use an editing statement, such as RESET, it must follow the CREATEstatement and the database-description statements when you create a descriptor. See“CREATE Statement” on page 201 for more information about the order of statements.

The RESET statement can take one or more of these arguments:

ALLfor access descriptors, resets all PC file columns that are defined to their defaultnames and format settings and reselects any dropped columns.

For view descriptors, ALL resets all columns that are selected so that nocolumns are selected for the view. You can then use the SELECT statement to

Page 219: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � RESET Statement 211

select new columns. See “SELECT Statement” on page 212 for more informationabout that statement.

column-identifiercan be either the PC file column name or the positional equivalent from the LISTstatement, which is the number that represents the column’s place in the accessdescriptor. For example, to reset the SAS variable name and format associatedwith the third column, submit this statement:

reset 3;

If the column name contains lowercase characters, special characters, ornational characters, enclose the name in quotation marks. You can reset as manycolumns as you want in one RESET statement, or use the ALL option to reset allcolumns.

When creating an access descriptor, the column-identifier is reset to its defaultname and format settings. When creating a view descriptor, the specified columnis no longer selected for the view.

Access DescriptorsWhen you create an access descriptor, the default setting for a SAS variable name is

a blank. However, if you have previously entered or modified any of the SAS variablenames, the RESET statement resets the modified names to the default names that aregenerated by the ACCESS procedure. How the default SAS variable names are setdepends on whether you included the ASSIGN statement. If you omitted ASSIGN orset it to NO, the default names are blank. If you set ASSIGN=YES, the default namesare the first eight characters of each PC file column name.

The current SAS variable format is also reset to the default SAS format, which wasdetermined from the column’s data type. Any columns that were previously dropped,but that are specified in the RESET statement, become available; they can be selectedin view descriptors that are based on this access descriptor.

View DescriptorsWhen you create a view descriptor, the RESET statement clears any columns that

were included in the SELECT statement (that is, it deselects the columns).When creating the view descriptor, if you reset a SAS variable and then select it

again within the same procedure execution, the SAS variable names and formats arereset to their default values, which are generated from the column names and datatypes. This applies only if you have omitted the ASSIGN statement or set the value toNO when you created the access descriptor on which the view descriptor is based. Ifyou specified ASSIGN=YES when you created the access descriptor, the RESETstatement has no effect on the view descriptor.

Page 220: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

212 SELECT Statement � Chapter 14

SELECT Statement

Selects PC file columns for the view descriptor.

Requirement: This statement is required.Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: view descriptorInteracts with: RESETNot allowed with: UPDATE

SELECT ALL|<’>column-identifier-1<’><…<’>column-identifier-n<’>>;

DetailsThe SELECT statement specifies which PC file columns in the access descriptor to

include in the view descriptor. This is a required statement, and you can use it onlywhen you create view descriptors. You cannot use the SELECT statement when youupdate a view descriptor.

If you use an editing statement, such as SELECT, it must follow the CREATEstatement when you create a view descriptor. See “CREATE Statement” on page 201 formore information about statement order.

The SELECT statement can take one or more of these arguments:

ALLincludes in the view descriptor all columns that were defined in the accessdescriptor and that were not dropped.

column-identifiercan be either the column name or the positional equivalent from the LISTstatement, which is the number that represents the column’s place in the accessdescriptor on which the view is based. For example, to select the first threecolumns, submit this statement:

select 1 2 3;

If the column name contains lowercase characters, special characters, ornational characters, enclose the name in quotation marks. You can select as manycolumns as you want in one SELECT statement.

SELECT statements are cumulative within the same view creation. Forexample, if you submit these SELECT statements, columns 1, 5, and 6 are selected.

select 1;select 5 6;

To clear all your current selections when creating a view descriptor, use theRESET ALL statement; you can then use another SELECT statement to selectnew columns.

Page 221: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � TYPE Statement 213

SUBSET Statement

Adds or modifies selection criteria for a view descriptor.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: view descriptor

SUBSET selection-criteria;

DetailsYou use the SUBSET statement to specify selection criteria when you create a view

descriptor. This statement is optional. If you omit it, the view retrieves all data (rows)in the PC file.

An editing statement, such as SUBSET, must follow the CREATE statement whenyou create a view descriptor. See “CREATE Statement” on page 201 for moreinformation about statement order.

TYPE Statement

Changes the expected data types of SAS variables.

Valid: for DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environments

TYPE <’>column-identifier-1< ’><=> C | N<…column-identifier-n <=> C | N>;

DetailsSAS data sets have two data types: character (C) and numeric (N). Spreadsheet files

have the same two data types: character (for labels and formula strings) and numeric(for numbers and formulas). Changing the default data type of a SAS variable in adescriptor file also changes its associated default format in the loaded file.

If you omit the TYPE statement, the database field types are generated from the PCfiles data types. You can change as many database field types as you want in one TYPEstatement.

This statement is not available for use with DBF files.

Page 222: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

214 UNIQUE Statement � Chapter 14

UNIQUE Statement

Generates SAS variable names based on PC file column names.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: view descriptorInteracts with: ASSIGNNot allowed with: UPDATEAlias: UN

UNIQUE <=> YES|NO|Y|N ;

DetailsThe UNIQUE statement specifies whether the SAS/ACCESS interface generates

unique SAS variable names for PC file columns for which SAS variable names have notbeen entered. You cannot use the UNIQUE statement when you are updating a viewdescriptor.

An editing statement, such as UNIQUE, must follow the CREATE statement whenyou create a view descriptor. See “CREATE Statement” on page 201 for moreinformation about the order of statements. The UNIQUE statement is affected bywhether you specified the ASSIGN statement when you created the access descriptor onwhich this view is based, as follows:

� If you specified the ASSIGN=YES statement, you cannot specify UNIQUE whencreating a view descriptor. YES causes SAS to generate unique names, soUNIQUE is not necessary.

� If you omitted the ASSIGN statement or specified ASSIGN=NO, you must resolveany duplicate SAS variable names in the view descriptor. You can use UNIQUE togenerate unique names automatically, or you can use the RENAME statement toresolve duplicate names yourself. See “RENAME Statement” on page 209 forinformation about that statement.

If duplicate SAS variable names exist in the access descriptor on which you arecreating a view descriptor, you can specify UNIQUE to resolve the duplication. Whenyou specify UNIQUE=YES, the SAS/ACCESS interface appends numbers to anyduplicate SAS variable names, thus making each variable name unique. (See “CREATEStatement” on page 201 for an explanation of how to create descriptors.)

If you specify UNIQUE=NO, the SAS/ACCESS interface continues to allow duplicateSAS variable names to exist. You must resolve these duplicate names before saving(and thereby creating) the view descriptor.

Note: It is recommended that you use the UNIQUE statement. If you omit it andSAS encounters duplicate SAS variable names in a view descriptor, your job fails.

The equal (=) sign is optional in the UNIQUE statement. �

Page 223: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � UPDATE Statement 215

UPDATE Statement

Updates a SAS/ACCESS descriptor file.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underWindows operating environmentsApplies to: access descriptor or view descriptorNot allowed with: ASSIGN, RESET, SELECT, UNIQUE

UPDATE libref.descriptor-name.ACCESS|VIEW ;

DetailsUse the UPDATE statement to perform a quick, simple update of a descriptor. For

example, if the PC database file for an existing access descriptor is relocated, you canuse UPDATE with the PATH option to specify the new location.

Descriptors modified by UPDATE are not checked for errors. Where validation iscrucial, use CREATE to overwrite a descriptor rather than UPDATE.

The descriptor is a name in three parts separated by periods (.):

librefidentifies the library container, which is a location either on the local system’s diskor that the local system can directly access. The libref must have been previouslycreated by a LIBNAME statement.

descriptor-nameis the descriptor you are updating. It must already exist in libref. (See “CREATEStatement” on page 201.)

ACCESSindicates that you are updating an access descriptor while VIEW indicates you areupdating a view descriptor.

Multiple UPDATE statements can appear in one ACCESS procedure block. If youuse UPDATE to change an access descriptor, one or more UPDATE statements might berequired for views that depend on the modified access descriptor.

You can use UPDATE and CREATE in the same PROC ACCESS block.

Updating Access DescriptorsThe order of statements in an UPDATE block is as follows:1 UPDATE must be the first statement after the PROC ACCESS statement with one

exception. If the block includes both UPDATE and CREATE statements, eitherstatement can be the first in the block.

2 Data source description statements: All are allowed.3 Editing statements: These editing statements are not allowed: ASSIGN, LIST,

RESET, SELECT, VIEW.

Since the UPDATE block does not validate the updated descriptor, the order ofdescription and editing statements does not matter.

Page 224: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

216 UPDATE Statement � Chapter 14

Updating View Descriptors

1 UPDATE must be the first statement after the PROC ACCESS statement with oneexception. If the block includes both UPDATE and CREATE statements, eitherstatement can be the first in the block.

2 Data source description statements: All are allowed.3 Editing statements. These editing statements are not allowed: ASSIGN, DROP,

RESET, SELECT, and UNIQUE.

Examples

Updating an ExistingThis example updates an existing access descriptor named AdLib.Product:

LIBNAME adlib ’c:\sasdata’;

PROC access dbms=wk4;update adlib.product.access;path=c:\lotus\specprod.wk4;rename productid prodid

fibername fiber;format productid 4.

weight e16.9fibersize e20.13width e16.9;

run;

This example updates the Employ access descriptor that is located in c:\sasdata,for the spreadsheet named c:\excel\employ.xls and updates the view descriptor forEmploy named Emp1204, located in c:\sasviews:

LIBNAME adlib ’c:\sasdata’;LIBNAME vlib ’c:\sasviews’;

PROC access dbms=xls;update adlib.employ.access;path=’c:\excel\employ.xls’;list all;

update vlib.emp1204.view;format empid 6.

salary dollar12.2jobcode 5.hiredate datetime9.birthdate datetime9.;

subset where jobcode=1204;run;

This example updates a second view descriptor that is based on Employ, namedBDays, that is also located in c:\sasviews. When you update a view, it is notnecessary to specify the access descriptor (using ACCDESC=) in the PROC ACCESSstatement. Note that FORMAT can be used because the Employ access descriptor wascreated with ASSIGN=NO.

LIBNAME vlib ’c:\sasviews’;

Page 225: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The ACCESS Procedure for PC Files � UPDATE Statement 217

PROC access dbms=xls;update vlib.bdays.view;format empid 6.

birthdate datetime7.;run;

Page 226: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

218

Page 227: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

219

C H A P T E R

15The DBLOAD Procedure

DBLOAD Procedure Overview 219DBLOAD Procedure Naming Conventions 220

DBLOAD Procedure Syntax 220

PROC DBLOAD Statement 221

ACCDESC Statement 221

DELETE Statement 222ERRLIMIT Statement 222

LABEL Statement 223

LIMIT Statement 223

LIST Statement 224

LOAD Statement 224

PATH Statement 225QUIT Statement 226

RENAME Statement 226

RESET Statement 227

WHERE Statement 228

DBLOAD Procedure Overview

The DBLOAD procedure for PC files is available only under Microsoft Windowsoperating environments. You can use the DBLOAD procedure with DBF, DIF, WK1,WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats. See : for alternate methods.There are alternate ways for accessing data in PC file formats under the UNIX,Microsoft Windows, and IBM z/OS operating environments. See: “Methods forAccessing PC Files Data” on page 3

This provides general reference information for the DBLOAD procedure. It presentsthe DBLOAD procedure options and statements that are common to all formats. Fileformat specific information for the SAS/ACCESS interface to your PC files is included inseparate sections.

Refer to SAS Language Reference: Dictionary and to the SAS documentation for youroperating environment for more information about:

� SAS data sets

� SAS libraries

� naming conventions

� help with terminology used in this procedure description

The DBLOAD procedure loads data to PCs and creates PC files. This data can befrom any of these items: a SAS data set, a PROC SQL view, a DATA step view, or aview descriptor from any SAS/ACCESS interface product. The DBLOAD procedure

Page 228: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

220 DBLOAD Procedure Naming Conventions � Chapter 15

associates each SAS variable with a PC file column. Then it assigns a default name anddata type to each column. You can use the default information or change it asnecessary. When you are finished customizing the columns, the procedure creates thePC file and loads it with the input data.

DBLOAD Procedure Naming Conventions

When you use the DBLOAD procedure to load a SAS data set into a PC file, the SASvariable names cannot exceed eight characters. This restriction is applied in order tohave compatibility with the SAS 6 naming conventions.

DBLOAD Procedure Syntax

When you use the DBLOAD procedure, you use different statements, depending onyour task, and your PC files. Not all statements are available with all PC file formats.Additional statements might be used with your PC file. For general syntax and specificdetails, see Chapter 6, “File Format-Specific Reference for the IMPORT and EXPORTProcedures,” on page 25..

PROC DBLOAD <DBMS=pc-file>

<DATA=< libref.>SAS data-set>;

Database-Description Statement

FMTLIB=LIBNAME.memberenable users to specify the location of a format library.Restriction: .

PATH=’path-and-filename.<PC file-extension>’|<’>filename<’>|fileref ;

Editing Statements

ACCDESC=< libref.>access-descriptor;

DELETE variable-identifier-1<…variable-identifier-n;>

ERRLIMIT=error-limit;

LABEL;

LIMIT=load-limit;

LIST <ALL|COLUMNS|FIELDS|variable-identifier>;

QUIT;

RENAME variable-identifier-1=<’>column-name-1<’><…variable-identifier-n<’>column-name-n<’>>;

RESET ALL|variable-identifier-1 <…variable-identifier-n >;

WHERE SAS where-expression;

Creating and Loading Statement

LOAD;

RUN;

Page 229: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBLOAD Procedure � ACCDESC Statement 221

PROC DBLOAD StatementRequirement: This statement is required.Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

PROC DBLOAD <DBMS=pc-file><DATA=< libref.>SAS data-set>;

Arguments

DBMS=pc-fileSpecifies the PC file format that you want to access. Specify DBMS=DBF for DBFfiles, DBMS=DIF for DIF files, DBMS=WK1 | WK3 | WK4 for WKn files,DBMS=MDB for MDB files, or DBMS=XLS for XLS files. The DBMS option isrequired.

DATA=<libref.>SAS data-setspecifies the input data set. The input data can be retrieved from a SAS data file,a PROC SQL view, a DATA step view, or a SAS/ACCESS view descriptor. If thedata set is permanent, you must use its two-level name, libref.SAS data-set. If youomit the DATA option, the default is the last SAS data set that was created.

ACCDESC Statement

Creates an access descriptor based on the new file.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsAliases: ACCESS and AD

ACCDESC=< libref.>access-descriptor;

DetailsThe ACCDESC statement creates an access descriptor based on the PC file that you

are creating and loading. After the new PC file is created and loaded, the accessdescriptor is automatically created. You must specify an access descriptor that does notalready exist.

An editing statement, such as ACCDESC , must be specified after the databasedescription statements when you create and load a file. See “LOAD Statement” on page224 for additional information.

Page 230: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

222 DELETE Statement � Chapter 15

DELETE Statement

Prevents variables from being loaded into the new PC file.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsInteracts with: RENAME, RESET

DELETE variable-identifier-1 <…variable-identifier-n>;

DetailsThe DELETE statement drops the specified SAS variables from the PC file being

created. The variable-identifier argument can be either the SAS variable name or thepositional equivalent from the LIST statement. The positional equivalent is the numberthat represents the variable’s place in the data set. For example, if you want to dropthe third variable, submit this statement:

delete 3;

You can drop as many variables as you want in one DELETE statement. If you dropmore than one variable, separate the identifiers with spaces, not commas.

Even if you drop a variable from the list of variables, the positional equivalents ofthe variables do not change. For example, if you drop the second variable, the thirdvariable is still referenced by the number 3, not 2.

An editing statement, such as DELETE, must be specified after thedatabase-description statements when you create and load a file. See “LOADStatement” on page 224 for more information.

ERRLIMIT Statement

Stops loading data after a specified number of errors.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsDefault: 100

ERRLIMIT=error-limit;

DetailsThe ERRLIMIT statement stops loading observations after the specified number of

errors has occurred while inserting rows into the file.The error-limit argument must be a nonnegative integer. Specify ERRLIMIT=0 to

allow an unlimited number of errors to occur.

Page 231: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBLOAD Procedure � LIMIT Statement 223

An editing statement, such as ERRLIMIT , must be specified after thedatabase-description statements when you create and load a file. See “LOADStatement” on page 224 for more information.

LABEL Statement

Causes column names to default to SAS labels.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsInteracts with: RENAME, RESET

LABEL;

DetailsThe LABEL statement causes the column names to default to the SAS variable labels

when the new table is created. If a SAS variable has no label, the variable name isused. If the label is too long to be a valid column name, the label is truncated.

For the LABEL statement to take effect, the RESET statement must be used afterthe LABEL statement.

An editing statement, such as LABEL, must be specified after thedatabase-description statements when you create and load PC files. See “LOADStatement” on page 224 for more information.

LIMIT Statement

Limits the number of observations that are loaded.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsDefault: 5000

LIMIT=load-limit;

DetailsThe LIMIT statement places a limit on the number of observations that can be

loaded into a new file. The maximum number for the limit statement varies with eachPC file. The load-limit argument must be a nonnegative integer. To load allobservations from your input data set, specify LIMIT=0.

If you omit the LIMIT statement, a maximum of 5,000 observations are inserted.

Page 232: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

224 LIST Statement � Chapter 15

LIST Statement

Lists information about the variables to load.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

Default: ALL

LIST <ALL|COLUMNS|FIELDS|variable-identifier>;

DetailsThe LIST statement lists information about all or some of the SAS variables to be

loaded into the new file. By default, the list is sent to the SAS log.The LIST statement can take one or more of these arguments:

ALLlists information about all variables in the input SAS data set, regardless ofwhether those variables are selected for the load.

COLUMNSlists information only about the input SAS variables that are selected for the load.This argument does not apply to DBF files.

FIELDSlists information only about the input SAS variables that are selected for the load.

variable-identifierlists information only about the specified variable. The variable-identifierargument can be either the SAS variable name or the positional equivalent. Thepositional equivalent is the number that represents the variable’s position in thedata set. For example, if you want to list information for the column associatedwith the third SAS variable, submit this statement:

list 3;

You can specify LIST as many times as you want while creating a file; specify LISTbefore the LOAD statement to see the entire table. LIST must be specified after thedatabase-description statements. See “LOAD Statement” on page 224 for moreinformation.

LOAD Statement

Creates and loads the new PC file.

Requirement: This statement is required.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

Page 233: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBLOAD Procedure � PATH Statement 225

LOAD;

DetailsThe LOAD statement causes the interface view engine to create a file and transfer

data to it from the input SAS data set, after the DBLOAD procedure is submitted. Thisstatement is required to create and load a new file.

When you create and load a file, you must place statements or groups of statementsin a certain order after the PROC DBLOAD statement and its options, as follows:

1 Database-description statements: PATH and your PC file specific statements.

2 Editing statements: ACCDESC , DELETE, ERRLIMIT, LABEL, LIMIT , LIST,RENAME, RESET, and WHERE. The order within this group usually does notmatter. See the individual statements for more information. QUIT is also anediting statement but using it immediately terminates PROC DBLOAD.

3 Creating and loading statement: LOAD must appear last before RUN in order tocreate and load the new table.

4 RUN statement: this statement is used to process the DBLOAD procedure.

PATH Statement

Indicates the name and path of the PC file to create and load.

Requirement: This statement is required.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

PATH=’path-and-filename <.PC-file-extension>’|<’>filename< ’>|fileref ;

DetailsThe PATH statement indicates the path and name of the PC file you want to create

and load. The length of the filename can vary with the operating environment. See theSAS documentation for your operating environment for any restrictions.

The PATH statement can take one of these arguments:

’path-and-filename<.PC-file-extension>’specifies the fully qualified path and filename. You must enclose the entire pathand filename in quotation marks, including the appropriate PC file extension, suchas .dbf, .dif, .wkn, .mdb, or .xls. If you omit the file extension, SAS/ACCESSsupplies it for you.

<’>filename <’>specifies the name of a file. The file must be located in your current (default)directory. If no extension is specified, the SAS/ACCESS interface supplies it foryou. If the filename includes characters:

Page 234: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

226 QUIT Statement � Chapter 15

� that is and invalid in SAS name� where the filename begins with a number

you must enclose the entire filename in quotation marks.

filerefspecifies a fileref that references the path and name of the file. (Assigning a filerefwith the FILENAME statement is described in Step-by-Step Programming withBase SAS Software.)

A file with the same name must not already exist. If one does exist, it is notoverwritten. An error message is written to the SAS log, and the PC file that isspecified in this statement is not loaded.

QUIT Statement

Exits the DBLOAD procedure.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsAlias: EXIT

QUIT;

DetailsThe QUIT statement exits the procedure without further processing.

RENAME Statement

Renames PC file columns.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environmentsInteracts with: DELETE, LABEL, RESETAlias: COLUMN

RENAME variable-identifier-1=<’>column-name-1<’><…variable-identifier-n =<’>column-name-n<’>>;

DetailsThe RENAME statement changes the names of the PC file’s columns that are

associated with the listed SAS variables. If you omit the RENAME statement, all

Page 235: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBLOAD Procedure � RESET Statement 227

column names default to the corresponding SAS variable names unless you specify theLABEL statement.

The variable-identifier argument can be either the SAS variable name or positionalequivalent from the LIST statement. The positional equivalent is the number thatrepresents where to place the variable in the data set. For example, submit thisstatement if you want to rename the column associated with the third SAS variable:

rename 3="employname";

The column-name argument must be a valid PC file column name. If the columnname includes lowercase characters, special characters, or national characters, youmust enclose the column name in quotation marks.

The RENAME statement enables you to include variables that you have previouslydeleted. For example, you submit these statements:

delete 3;rename 3=’empname’;

The DELETE statement first drops the third variable. The RENAME statement thenincludes the third variable and assigns the name EMPNAME and the default columntype to it.

You can rename as many variables as you want in one RENAME statement. TheRENAME statement overrides the LABEL statement for columns that are renamed.

An editing statement, such as RENAME, must be specified after thedatabase-description statements when you create and load a PC file. See “LOADStatement” on page 224 for more information.

RESET Statement

Resets column names and data types to their default values.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

Interacts with: DELETE, LABEL, RENAME

RESET ALL|variable-identifier-1<…variable-identifier-n>;

DetailsThe RESET statement resets the columns that are associated with the listed SAS

variables to the default column name, column data type, and ability to accept nullvalues. If you specify ALL, all columns are reset to their default values, and anydeleted columns are restored with their default values.

The variable-identifier argument can be either the SAS variable name or thepositional equivalent from the LIST statement. The positional equivalent is the numberthat represents the variable’s place in the data set. For example, if you want to resetthe column associated with the third SAS variable, submit this statement:

reset 3;

You can reset as many columns as you want in one RESET statement.

Page 236: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

228 WHERE Statement � Chapter 15

You must use the RESET statement after the LABEL statement for the LABELstatement to take effect.

An editing statement, such as RESET, must be specified after thedatabase-description statements when you create and load a PC file. See “LOADStatement” on page 224 for more information.

WHERE Statement

Loads a subset of data into the new PC file.

Valid: for DBF, DIF, WK1, WK3, WK4, Excel 4, Excel 5, and Excel 95 file formats underMicrosoft Windows operating environments

WHERE SAS where-expression;

DetailsThe WHERE statement loads a subset of observations into the new PC file. The SAS

where-expression must be a valid SAS WHERE statement that uses SAS variablenames (not column names) as defined in the input data set. This example loads onlythe observations in which the SAS variable Country has the value Brazil.

where country=’Brazil’;

For more information about the syntax of the SAS WHERE statement, see SASLanguage Reference: Dictionary.

An editing statement, such as WHERE, must be specified after thedatabase-description statements when you create and load a PC File. See “LOADStatement” on page 224 for more information.

Page 237: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

229

C H A P T E R

16File-Specific Reference for theACCESS and DBLOAD Procedures

ACCESS Procedure: XLS Specifics 229Overview: ACCESS Procedure for XLS Files 230

ACCESS Procedure Syntax for XLS Files 230

ACCESS Procedure Data Conversions for XLS Files 232

DBLOAD Procedure: XLS Specifics 236

Overview: DBLOAD Procedure for XLS Files 236DBLOAD Procedure Syntax for XLS Files 236

DBLOAD Procedure Data Conversions for XLS Files 238

Setting Environment Variables for XLS Files 240

ACCESS Procedure: WKn Specifics 241

ACCESS Procedure Syntax for WKn Files 241

ACCESS Procedure Data Conversions for WKn Files 243DBLOAD Procedure: WKn Specifics 244

DBLOAD Procedure Syntax for WKn Files 245

DBLOAD Procedure Data Conversions for WKn Files 246

Setting Environment Variables for WKn Files 247

ACCESS Procedure: DBF Specifics (Windows) 248ACCESS Procedure Syntax for DBF Files 248

ACCESS Procedure Data Conversions for DBF Files 249

DBLOAD Procedure: DBF Specifics (Windows) 249

DBLOAD Procedure Syntax for DBF Files 249

DBLOAD Procedure Data Conversions for DBF Files 252Setting Environment Variables for DBF Files 252

ACCESS Procedure: DIF Specifics 252

ACCESS Procedure Syntax for DIF Files 253

ACCESS Procedure Data Conversions for DIF Files 255

Datetime Conversions in the ACCESS Procedure 255

DBLOAD Procedure: DIF Specifics 255DBLOAD Procedure Syntax for DIF Files 256

Datetime Conversions in the DBLOAD Procedure 257

Setting Environment Variables for DIF Files 257

DIF File Data Types 258

ACCESS Procedure: XLS Specifics

Page 238: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

230 Overview: ACCESS Procedure for XLS Files � Chapter 16

Overview: ACCESS Procedure for XLS FilesChapter 14, “The ACCESS Procedure for PC Files,” on page 195 contains general

information about this feature. This section provides XLS-specific syntax for the Accessprocedure and describes Access procedure data conversions.

ACCESS Procedure Syntax for XLS FilesTo create an access descriptor, you use the DBMS=XLS option and six

database-description statements: PATH=, GETNAMES=, RANGE=, SCANTYPE=,SKIPROWS=, and WORKSHEET=. These database-description statements supplyXLS-specific information to SAS. They must immediately follow the CREATEstatement. In addition to the database-description statements, editing statements canfollow the database-description statements.

Database-description statements are required only when you create accessdescriptors. Because the XLS information is stored in an access descriptor, you do notneed to repeat the information when you create view descriptors.

The SAS/ACCESS interface to XLS uses the following procedure statements:

PROC ACCESS DBMS=XLS | EXCEL;CREATE libref.member-name.ACCESS | VIEW;UPDATE libref.member-name.ACCESS | VIEW;

GETNAMES <=> YES | NO | Y | N;PATH= ’path-and-filename’<.XLS> ’| < ’>filename<’> | fileref;RANGE <=> <’>range-name<’> | ’range-address’;SCANTYPE <=> YES | NO | Y | N | <number-of-rows>;SKIPROWS <=> number-of-rows-to-skip;WORKSHEET <=> worksheet-name;ASSIGN <=> YES | NO | Y | N ;DROP <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;FORMAT <’>column-identifier-1<’> <=> SAS format-name-1

<…<’>column-identifier-n<’> <=> SAS format-name-n> ;LIST <ALL | VIEW | <’>column-identifier<’>> ;MIXED <=> YES | NO | Y | N;RENAME <’>column-identifier-1<’> <=> SAS variable-name-1

<…<’>column-identifier-n<’> <=> SAS variable-name-n> ;RESET ALL | <’>column-identifier-1<’> <…<’>column-identifier-n<’>> ;SELECT ALL | <’>column-identifier-1< ’> <…<’>column-identifier-n<’>> ;SUBSET selection-criteria ;TYPE column-identifier-1 <=> C | N <… column-identifier-n <=> C | N>;UNIQUE <=> YES | NO | Y | N ;

RUN;

Note: By default, the Access procedure uses Excel 5 files, which have an identicalformat to Excel 95 files. �

Note: Microsoft Excel 4, 5, and 7 limits are: columns – 256, rows - 16,384. �

Page 239: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Syntax for XLS Files 231

The QUIT statement is also available in the Access procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the XLS-specific statements:

GETNAMES <=> YES|NO| Y | N;determines whether SAS variable names are generated from column names in thefirst row of the range when an access descriptor is created. When you update adescriptor, you are not allowed to specify the GETNAMES statement.

The GETNAMES statement is optional. If you omit it, the default valueGETNAMES=NO is used, and the XLS interface generates the SAS variablenames VAR0, VAR1, VAR2, and so on. If you specify GETNAMES=YES, the SASvariable names are generated from the column names in the first row of the range.GETNAMES=YES also sets the SKIPROWS value to 1.

You can change the default value from NO to YES by setting the SS_NAMESenvironment variable. For more information, see “Setting Environment Variablesfor XLS Files” on page 240.

The GETNAMES= statement is a database-description statement. It mustfollow the CREATE= statement and precede any editing statements when youcreate a descriptor

RANGE <=> <’>range-name<’> | ’range-address’;subsets a specified section of an XLS file worksheet. The range-name is the namethat is assigned to a range address within the worksheet. Range names can be upto 15 characters long and are not case sensitive.

The range-address is identified by the top-left cell that begins the range and thebottom-right cell that ends the range within the XLS worksheet file. Thebeginning and ending cells are separated by two periods. For example, the rangeaddress C9..F12 indicates a cell range that begins at Cell C9, ends at Cell F12,and includes all cells in between.

The RANGE statement is optional. If you omit RANGE, the entire worksheet isaccessed as the default range.

The RANGE is a database-description statement. It must follow the CREATEstatement and precede any editing statements when you create a descriptor.

SCANTYPE <=> YES|NO|Y|N| <number-of-rows>;finds the most common Excel data type and format for each column in a specifiednumber of rows in an XLS worksheet in order to generate the default SAS format.By default, formats that Excel finds in the first row of the entire worksheet or inthe first row of a range (if specified) in the worksheet generate SAS variableformats.

The SCANTYPE statement is optional, and its default value is NO. If youspecify YES, the Access procedure scans data types and formats of all rows in eachcolumn of the worksheet or range and then uses the most common one to generatethe default SAS format for each column. If you specify a number of rows, theAccess procedure scans only the specified number of rows and returns the mostcommon format.

If you specify the SKIPROWS= statement, the ACCESS procedure skips thespecified rows and starts scanning from the next row. For example, if you specifySKIPROWS=3, the Access procedure skips the first three rows and beginsscanning the data type and format on the fourth row.

You can change the default value to YES by setting the SS_SCAN environmentvariable. For more information, see “Setting Environment Variables for XLS Files”on page 240.

Specifying SCANTYPE=0 is equivalent to specifying SCANTYPE=NO.

Page 240: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

232 ACCESS Procedure Data Conversions for XLS Files � Chapter 16

The SCANTYPE = statement is a database-description statement. It mustfollow the CREATE= statement and precede any editing statements when youcreate a descriptor.

SKIPROWS <=> number-of-rows-to-skip;specifies the number rows, beginning at the top of the range in the XLS file, toskip when you are reading data from the XLS file. The default value forSKIPROWS is 0. The skipped (or ignored) rows often contain information such ascolumn labels, names, or underscores rather than input data.

If GETNAMES=YES, the default value of SKIPROWS automatically changes to1. The first row of data and formats after SKIPROWS= in a range is used togenerate the SAS variable types and formats. However, you can use theSCANTYPE= statement to scan the formats of a specified number of rows and usethe most common data type and format to generate the default SAS variable typesand formats. For more information, see .See also: “Setting Environment Variables for XLS Files” on page 240Note: The SKIPROWS statement is a database-description statement. It must

follow the CREATE statement and precede any editing statements when youcreate a descriptor.

WORKSHEET <=> <’>worksheet-name<’>;identifies one worksheet from a group of worksheets while you are reading from anXLS file. The worksheet-name is a 31-character name and is not case sensitive.For example, specifying WORKSHEET=SHEET2 identifies worksheet 2 from agroup of worksheets

The WORKSHEET statement is optional. For Excel 4 files, there is only oneworksheet identifier, WORKSHEET1. Therefore, the WORKSHEET statement isignored. Under Excel 5, the default value is SHEET1. If you change the defaultworksheet from within Excel, you can either supply the new worksheet name orsupply the worksheet’s value (such as Sheet5 ).

The WORKSHEET statement is a database-description statement. It mustfollow the CREATE statement and precede any editing statements when youcreate an access descriptor.

ACCESS Procedure Data Conversions for XLS FilesYou use the Access procedure to define descriptors that identify spreadsheet data and

the conversions necessary to use that data in SAS programs. The Microsoft Excel labeldata type is formatted as a SAS character type, and the Microsoft Excel number datatype is formatted as a SAS numeric type.

Fonts, attributes, and colors in the XLS files are not read into SAS data sets.However, the Access procedure supports most of the XLS number formats andautomatically converts them to the corresponding SAS formats. XLS data strings thatare longer than 200 characters are truncated during conversion to SAS data sets. XLSfiles that create a SAS data file can contain up to 256 variables and 16,384 observations.

The following table shows the default SAS variable formats that the ACCESSprocedure assigns to each type of standard XLS file data.

Table 16.1 Default SAS Variable Formats for XLS File Data

XLS File Data SAS Variable Format

Data Type XLS Format String Type Format

Char1 @2 Char $w.

Numeric3 General Num BEST

Page 241: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Data Conversions for XLS Files 233

XLS File Data SAS Variable Format

Data Type XLS Format String Type Format

Numeric 0 Num w.d

Numeric 0.00 Num w.d

Numeric #,##0 Num COMMAw.d

Numeric #,##0.00 Num COMMAw.d

Numeric #,##0_);(#,##0) Num NEGPARENw.d

Numeric #,##0_);[Red](#,##0) Num NEGPARENw.d

Numeric #,##0.00_);(#,##0.00) Num NEGPARENw.d

Numeric #,##0.00_);[Red](#,##0.00) Num NEGPARENw.d

Numeric $#,##0_);($#,##0) Num DOLLARw.d

Numeric $#,##0_);[Red]($#,##0) Num DOLLARw.d

Numeric ($#,##0.00_);($#,##0.00) Num DOLLARw.d

Numeric ($#,##0.00_);[Red]($#,##0.00) Num DOLLARw.d

Numeric _($*#,##0_);_($*(#,##0);_($*"-"_);_(@_)

Num DOLLARw.d

Numeric _(*#,##0_);_(*(#,##0);_(*"-"_);_(@_)

Num NEGPARENw.d

Numeric _($*#,##0.00_);_($*(#,##0.00);_($*"-"??_);_(@_)

Num DOLLARw.d

Numeric _(*#,##0.00_);_(*(#,##0.00);_(*"-"??_);_(@_)

Num NEGPARENw.d

Numeric 0% Num PERCENTw.d

Numeric 0.00% Num PERCENTw.d

Numeric 0.00E+00 Num Ew.d

Numeric ##0.0E+0 Num Ew.d

Numeric m/d/yy Num MMDDYYw.

Numeric d-mmm-yy Num MMDDYYw.

Numeric d-mmm Num DATEw.

Numeric mmm-yy Num MONYYw.

Numeric h:mm AM/PM Num TIMEw.

Numeric h:mm:ss AM/PM Num TIMEw.

Numeric h:mm Num TIMEw.

Numeric hh:mm Num TIMEw.

Numeric h:mm:ss Num TIMEw.

Numeric hh:mm:ss Num TIMEw.

Numeric m/d/yy h:mm Num DATETIMEw.

Numeric ddmmmyy Num DATEw.

Numeric ddmmmyyyy:hh:mm:ss Num DATETIMEw.

Page 242: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

234 ACCESS Procedure Data Conversions for XLS Files � Chapter 16

XLS File Data SAS Variable Format

Data Type XLS Format String Type Format

Numeric dd Num DATEw.

Numeric dd/mm/yy Num DDMMYYw.

Numeric dddd Num DATEw.

Numeric mm/dd/yy Num MMDDYYw.

Numeric mm:ss Num MMSSw.

Numeric mm yy Num MONYYw.

Numeric mm yyyy Num MONYYw.

Numeric mm:yy Num MONYYw.

Numeric mm:yyyy Num MONYYw.

Numeric mm-yy Num MONYYw.

Numeric mm-yyyy Num MONYYw.

Numeric mmyy Num MONYYw.

Numeric mmyyyy Num MONYYw.

Numeric mm.yy Num MONYYw.

Numeric mm.yyyy Num MONYYw.

Numeric mm/yy Num MONYYw.

Numeric mm/yyyy Num MONYYw.

Numeric mmmm Num MONYYw.

Numeric m Num MONYYw.

Numeric mmmyy Num MONYYw.

Numeric mmmyyyy Num MONYYw.

Numeric dddd, mmmm dd, yyyy Num MONYYw.

Numeric dddd, dd mmmm yyyy Num MONYYw.

Numeric mmmm dd, yyyy Num MONYYw.

Numeric dd mmmm yyyy Num MONYYw.

Numeric yy Num YYMMDDw.

Numeric yyyy Num YYMMDDw.

Numeric yy mm Num YYMMDDw.

Numeric yyyy mm Num YYMMDDw.

Numeric yy:mm Num YYMMDDw.

Numeric yyyy:mm Num YYMMDDw.

Numeric yy-mm Num YYMMDDw.

Numeric yyyy-mm Num YYMMDDw.

Numeric yymm Num YYMMDDw.

Numeric yyyymm Num YYMMDDw.

Numeric yy.mm Num YYMMDDw.

Page 243: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Data Conversions for XLS Files 235

XLS File Data SAS Variable Format

Data Type XLS Format String Type Format

Numeric yyyy.mm Num YYMMDDw.

Numeric yy/mm Num YYMMDDw.

Numeric yyyy/mm Num YYMMDDw.

Numeric yy-mm-dd Num YYMMDDw.

Numeric yymmm Num YYMMDDw.

Numeric yyyymmm Num YYMMDDw.

1 Label data.2 The XLS character format for Excel Version 5.3 Number, formula, or missing data.

Table 16.2 Default SAS Variable Formats for Customized XLS Format Strings

XLS File Data SAS Variable Format

Data Type XLS Format String Type Format

Numeric "$" Num DOLLARw.d

Numeric "E" Num Ew.d

Numeric "m, d and y" Num MMDDYYw.

Numeric "m and h" Num TIMEw.d

Numeric "m and s" Num TIMEw.d

Numeric "m and y" Num MONYYw.

Numeric "m" Num DATEw.

Numeric "d" Num DATEw.

Numeric "y" Num DATEw.

Numeric "0.0" Num w.d

Numeric Fraction values (#?/?) Num BESTw.d

Numeric Percent values (0.0%) Num PERCENTw.d

Numeric All others Num BESTw.d

w is based on Excel column width. The Excel format string controls .d.If XLS files data falls outside of the valid SAS data ranges, you receive an error

message in the SAS log when you try to access the data.The SAS/ACCESS interface does not fully support the Microsoft Excel hidden and

text formats. XLS data in hidden format is displayed in SAS data sets. However, youcan drop the hidden column when you are creating the access descriptor. If you want todisplay a formula in text format, add a space to indicate that the formula entry is alabel. Otherwise, the results of the formula display.

You can change the default value from NO to YES by setting the SS_MIXEDenvironment variable. For more information, see “Setting Environment Variables forXLS Files” on page 240.

If you set the SS_MIXED environment variable to YES, numeric values in XLS filesare converted to character strings in SAS data sets if the corresponding SAS variabletype is specified as character.

Page 244: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

236 DBLOAD Procedure: XLS Specifics � Chapter 16

DBLOAD Procedure: XLS Specifics

Overview: DBLOAD Procedure for XLS FilesChapter 15, “The DBLOAD Procedure,” on page 219 contains general information

about this feature. This section provides XLS-specific syntax for the DBLOADprocedure and describes DBLOAD procedure data conversions.

DBLOAD Procedure Syntax for XLS FilesTo create and load an XLS table, the SAS/ACCESS interface to XLS uses the

following statements:

PROC DBLOAD DBMS=XLS | EXCEL <DATA=<libref.>SAS data-set>;PATH=’path-and-filename<.XLS>’ | <’>filename<’> | fileref;VERSION <=> EXCEL-product-number;PUTNAMES <=> YES | NO | Y | N;ACCDESC= <libref.>access-descriptor;

DELETE variable-identifier-1 <…variable-identifier-n>;ERRLIMIT= error-limit;FORMAT SAS variable-name-1 SAS format-1 <=>

<…SAS variable-name-n SAS format-n>;LABEL;LIMIT=load-limit;LIST <ALL | COLUMNS | FIELDS | variable-identifier>;RENAME variable-identifier-1 <=> <’>column-name-1<’>

<…variable-identifier-n = <’>column-name-n<’>>;RESET ALL | variable-identifier-1 <…variable-identifier-n>;

WHERE SAS where-expression ;LOAD ;

RUN ;

The QUIT statement is also available in the DBLOAD procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the XLS-specific statements:

FORMAT SAS variable-name-1 SAS format-1 <…SAS variable-name-n SASformat-n>;

assigns a temporary format to a SAS variable in the input SAS data set. Thisformat temporarily overrides any other format for the variable. The assignmentlasts only for the duration of the procedure. Assign formats to as many variablesas you want in one FORMAT statement.

Use FORMAT when you want to change the format, column width, or thenumber of decimal digits for columns being loaded into the PC file. For example, ifyou change the SAS variable format 12.1 to DOLLAR15.2, the column format ofthe loaded data changes from a fixed numeric format with a column width of 12

Page 245: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure Syntax for XLS Files 237

and one decimal digit to a currency format with a column width of 15 and twodecimal digits.

PUTNAMES <=> YES|NO|Y|N;writes column names to the first row of the new XLS file. The column names canbe default SAS variables names or, if you specify the LABEL statement, SASvariable labels. You can modify the column names using the RENAME statement.

The PUTNAMES statement is optional. If you omit PUTNAMES, data is readfrom the data set and written to the XLS file—beginning in the first row of theXLS file—and no column names are written to the file.

You can change the default value to YES by setting the SS_NAMESenvironment variable. For more information, see “Setting Environment Variablesfor XLS Files” on page 240.

VERSION <=> Excel-product-number;specifies the version number of the Excel product you are using, such as Excel 5.The Excel-product-number argument can be one of the following values:

Table 16.3 Excel Versions

Value Description

3

MicrosoftExcelVersion3

4

MicrosoftExcelVersion4

5

MicrosoftExcelVersion5

7

MicrosoftExcel95(alsocalledMicrosoftExcelVersion7)

The DBLOAD procedure chooses the default version of Excel depending onwhich operating environment you use. If you use Windows, DBLOAD uses Excel 5.Excel 5 files have the identical format to Excel 95 files.

The DBLOAD procedure does not support Excel 97 or later files. Forinformation about accessing these files, see “Supported Data Sources andEnvironments” on page 7.

Specify VERSION before the TYPE statement in order to get the correct datatypes for your new XLS table.

Page 246: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

238 DBLOAD Procedure Data Conversions for XLS Files � Chapter 16

DBLOAD Procedure Data Conversions for XLS FilesThis section explains how SAS data is read into Microsoft Excel data when a table is

loaded. In this conversion, the SAS character data type is converted into the MicrosoftExcel label type and the SAS numeric type is converted into the Microsoft Excelnumber type.

The SAS/ACCESS interface automatically converts SAS formats to the same orassociated Microsoft Excel formats and column widths. However, you can temporarilyassign other formats and column widths to SAS variables by using the FORMATstatement so that the loaded XLS file columns have the formats you want. Thefollowing table shows SAS variable types and formats and the XLS data types, formats,and column widths to which you can assign them.

Note: The FORMAT statement in the DBLOAD procedure changes only the formatof SAS variables while you are creating and loading the XLS files. When the procedureis completed, the formats of SAS variables return to their original settings. �

XLS date and time values are numeric data.

Table 16.4 Converting SAS Variable Formats to XLS File Data

SAS Variable Format XLS File Data

Type Format XLS Format String Data Type

Char " " General LABEL

Char $CHAR General LABEL

Char $ General LABEL

Num BESTw.d General NUMBER

Num COMMAw.d #,##0 NUMBER

Num COMMAXw.d #,##0 NUMBER

Num DATEw. ddmmmyy NUMBER

Num DATETIMEw.d ddmmmyyyy:hh:mm:ss NUMBER

Num DAYw. dd NUMBER

Num DDMMYYw. dd/mm/yy NUMBER

Num DOLLARw.d "$"#,##0_);("$"#,##0) NUMBER

Num DOLLARXw.d "$"#,##0_);("$"#,##0) NUMBER

Num DOWNAMEw.d dddd NUMBER

Num Ew. 0.00E+00 NUMBER

Num HHMMw.d h:mm NUMBER

Num HOURw.d h:mm NUMBER

Num JULDAYw. m/d/yy NUMBER

Num JULIANw. m/d/yy NUMBER

Num MMDDYYw. mm/dd/yy NUMBER

Num MMSSw.d mm:ss NUMBER

Num MMYYxw. mm yy NUMBER

Num MMYYC mm:yy NUMBER

Page 247: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure Data Conversions for XLS Files 239

SAS Variable Format XLS File Data

Type Format XLS Format String Data Type

Num MMYYD mm-yy NUMBER

Num MMYYN mmyy NUMBER

Num MMYYP mm.yy NUMBER

Num MMYYS mm/yy NUMBER

Num MONNAMEw. mmmm NUMBER

Num MONTHw. m NUMBER

Num MONYYw. mmmyy NUMBER

Num NEGPARENw.d #,##0_);(#,##0) NUMBER

Num NENGOw. m/d/yy NUMBER

Num PERCENTw.d 0% NUMBER

Num QTRw. m/d/yy NUMBER

Num QTRRw. m/d/yy NUMBER

Num SSNw. 000-00-0000 NUMBER

Num TIMEw.d h:mm:ss NUMBER

Num TODw. h:mm:ss NUMBER

Num W 0 NUMBER

Num WEEKDATEw. dddd, mmmm dd, yyyy NUMBER

Num WEEKDATXw. dddd, dd mmmm yyyy NUMBER

Num WEEKDAYw. m/d/yy NUMBER

Num WORDDATEw. mmmmdd, yyyy NUMBER

Num WORDDATXw. dd mmmm yyyy NUMBER

Num YEARw. yy or yyyy NUMBER

Num YYMM yy mm NUMBER

Num YYMMC yy:mm NUMBER

Num YYMMD yy-mm NUMBER

Num YYMMN yymm NUMBER

Num YYMMP yy.mm NUMBER

Num YYMMS yy/mm NUMBER

Num YYMMDDw. yy-mm-dd NUMBER

Num YYMONw. yymmm NUMBER

Num Zw.d 0w.d NUMBER

Num FRACTw. # ?/? NUMBER

Excel column widths are set to w and display in the column. If the data is largerthan column width, it displays as pound signs (###). In that case, you can view it byadjusting the column width.

Page 248: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

240 Setting Environment Variables for XLS Files � Chapter 16

Setting Environment Variables for XLS FilesYou can change the default behavior of the Access procedure and the DBLOAD

procedure by setting environment variables in your SAS configuration file. You can setthree SAS/ACCESS environment variables: SS_MIXED, SS_NAMES, and SS_SCAN.Setting these variables in your SAS configuration file defines how the interface works.

The configuration file omits these three environment variables. Their default valuesare NO.

SS_MIXED YES|NOYES allows both Microsoft Excel numeric and character data in a column to bedisplayed as SAS character data. The Microsoft Excel numeric data is converted toits character representation when its corresponding SAS variable type is definedas character.

NO does not convert Microsoft Excel numeric data in a column into SAScharacter data. Microsoft Excel numeric data is read in as SAS missing valueswhen its corresponding SAS variable type is defined as character. NO is thedefault.

Setting the SS_MIXED environment variable changes the default value of theMIXED statement in the Access procedure.

SS_NAMES YES|NOYES allows the Access procedure to generates SAS variable names from columnnames in the first row of the worksheet or the specified range of the worksheet. Itthen reads data from the second row. YES in the DBLOAD procedure writescolumn names using SAS variable names or SAS variable labels to the first row ofthe new XLS file, reads the data from the data set, and writes it to the XLS filebeginning with the second row.

NO in the Access procedure generates the SAS variable names VAR0, VAR1,VAR2, and so on, and reads data from the first row of the worksheet or specifiedrange. NO in the DBLOAD procedure reads the data from the data set and writesit to the XLS file beginning with the first row. NO is the default.

Setting the SS_NAMES environment variable changes the default value of theGETNAMES statement in the Access procedure and the PUTNAMES statement inthe DBLOAD procedure.

SS_SCAN YES | NO | number-of-rowsYES scans the data type and format of rows in a worksheet or specified rangeafter skipping the number of rows specified in the SKIPROWS statement. Afterscanning the rows, SS_SCAN finds the most common Microsoft Excel data typeand format in order to generate the default SAS data type and format. If anumber of rows is specified, SAS/ACCESS scans the data type and format onlyfrom these rows.

NO uses the type and format of the first row in a worksheet or specifiedrange—after skipping the number of rows specified in SKIPROWS—to generatethe default SAS data type and format. NO is the default.

Number-of-rows scans only the type and format of the specified number of rows.Setting the number of rows is more efficient because data is read from only thespecified number of rows rather than the entire file.

Setting the SS_SCAN environment variable changes the default value of theSCANTYPE statement in the Access procedure.

Page 249: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Syntax for WKn Files 241

ACCESS Procedure: WKn SpecificsChapter 14, “The ACCESS Procedure for PC Files,” on page 195 contains general

information about this feature. This section provides WKn specific syntax for theACCESS procedure and describes ACCESS procedure data conversions.

ACCESS Procedure Syntax for WKn FilesTo create an access descriptor, use the DBMS=WKn option and these

database-description statements:� GETNAMES=� PATH=� RANGE=� SCANTYPE=� SKIPROWS=� WORKSHEET=

These database-description statements supply WKn specific information to SAS andmust immediately follow the CREATE or UPDATE statement that specifies the accessdescriptor to be created or updated. In addition to the database-description statements,you can use editing statements when you create an access descriptor. These editingstatements must follow the database-description statements.

Database-description statements are required only when you create accessdescriptors. Because WKn information is stored in an access descriptor, you do not needto repeat this information when you create view descriptors.

The SAS/ACCESS interface to WKn uses the following procedure statements:

PROC ACCESS DBMS=WK1|WK3|WK4;CREATE libref.member-name.ACCESS | VIEW;UPDATE libref.member-name.ACCESS | VIEW;

PATH= ’path-and-filename<.WK1 | .WK3 | .WK4>’| <’>filename<’>| fileref;GETNAMES <=> YES | NO | Y | N;RANGE <=><’>range-name<’>| ’range-address’;SCANTYPE <=> YES | NO | Y | N | <number-of-rows>;SKIPROWS <=> number-of-rows-to-skip;WORKSHEET <=> worksheet-letter| <’>worksheet-name<’>;ASSIGN <=> YES | NO | Y | N;DROP <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;FORMAT <’>column-identifier-1<’> <=> SAS format-name-1

<…<’>column-identifier-n<’><=> SAS format-name-n>;LIST <ALL | VIEW | <’>column-identifier<’>>;MIXED <=> YES | NO | Y | N;RENAME <’>column-identifier-1<’> <=> SAS variable-name-1

<…<’>column-identifier-n<’> <=> SAS variable-name-n>;RESET ALL | <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;SELECT ALL | <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;SUBSET selection-criteria;

Page 250: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

242 ACCESS Procedure Syntax for WKn Files � Chapter 16

TYPE column-identifier-1<=> C | N <…column-identifier-n <=> C | N>;UNIQUE <=> YES | NO | Y | N ;

RUN ;

The QUIT statement is also available in the Access procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the WKn specific statements:

GETNAMES <=> YES | NO | Y | N;determines whether SAS variable names are generated from column names in thefirst row of the Lotus range when an access descriptor is created. When youupdate a descriptor, you are not allowed to specify the GETNAMES statement.

The GETNAMES statement is optional. If you omit it, the default valueGETNAMES=NO is used, and the SAS/ACCESS interface generates the SASvariable names VAR0, VAR1, VAR2, and so on. If you specify GETNAMES=YES,the SAS variable names are generated from the column names in the first row ofthe Lotus range. GETNAMES=YES also sets the default value of SKIPROWS to 1.

You can change the default value from NO to YES by setting the SS_NAMESenvironment variable. For more information, see “Setting Environment Variablesfor WKn Files” on page 247.

The GETNAMES statement is a database-description statement. It must followthe CREATE statement and precede any editing statements when you create adescriptor.

RANGE <=> <’>range-name<’> | ’range-address’;subsets a specified section of a WKn file worksheet. The range-name is the namethat is assigned to a range address within the worksheet. Range names can be upto 15 characters long and are not case sensitive. If you specify a range name, thename must have been previously defined in the WKn file. The range-address isidentified by the top-left cell that begins the range and the bottom-right cell thatends the range within the WKn worksheet file. The beginning and ending cells areseparated by two periods. For example, the range address C9..F12 indicates a cellrange that begins at Cell C9, ends at Cell F12, and includes all cells in between.

The RANGE statement is optional. If you omit RANGE, the entire worksheet isaccessed as the default range.

The RANGE is a database-description statement. It must follow the CREATEstatement and precede any editing statements when you create a descriptor.

SCANTYPE <=> YES | NO | Y | N | <number-of-rows>;finds the most common Lotus 1-2-3 format for each column in a specified numberof rows in a WKn worksheet to generate the SAS format. By default, SAS variableformats are generated from the Lotus 1-2-3 formats that are found in the first rowof the worksheet or in the range of the worksheet (if you specified a range).

The SCANTYPE statement is optional, and its default value is NO. If you specifyYES, the ACCESS procedure scans the Lotus 1-2-3 formats of all the rows in eachcolumn of the range and uses the most common format to generate the defaultSAS format for each column. If you specify a number of rows, the Access procedurescans only the specified number of rows and returns the most common format.

If you specify the SKIPROWS statement, the ACCESS procedure skips thespecified rows and starts scanning the Lotus 1-2-3 format from the next row. Forexample, if you specify SKIPROWS=3, the Access procedure skips the first threerows and begins scanning the formats on the fourth row.

You can change the default value to YES by setting the SS_SCAN environmentvariable. For more information, see “Setting Environment Variables for WKnFiles” on page 247.

Page 251: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Data Conversions for WKn Files 243

Specifying SCANTYPE=0 is equivalent to specifying SCANTYPE=NO.The SCANTYPE statement is a database-description statement. It must follow

the CREATE statement and precede any editing statements when you create adescriptor.

SKIPROWS <=> number-of-rows-to-skip;specifies the number of rows, beginning at the top of the range in the WKn file, toignore when you are reading data from the WKn file. The default value forSKIPROWS is 0. The skipped (or ignored) rows often contain information such ascolumn labels or names, or underscores rather than input data.

If GETNAMES=YES, the default value of SKIPROWS automatically changes to1. The first row of data and formats after SKIPROWS in a range is used togenerate the SAS variable types and formats. However, you can use theSCANTYPE= statement to scan the formats of specified rows. Then use the mostcommon type and format to generate the SAS variable types and formats.

The SKIPROWS= statement is a database-description statement. It must followthe CREATE statement and precede any editing statements when you create adescriptor. The CREATE= option precedes the SKIPROWS= option. Editingstatements follow the SKIPROWS= option.

WORKSHEET <=> worksheet-letter | <’>worksheet-name<’>identifies a particular worksheet when you are reading from a WKn file thatcontains more than one worksheet. You can specify a worksheet name or aworksheet letter using the WORKSHEET statement. Worksheet names can be upto 15 characters long and are not case sensitive. A worksheet letter is a one- ortwo-letter alpha character. For WK1 files, there is only one worksheet letter:worksheet A. For WK3 and WK4 files, there can be up to 256 different worksheetletters: worksheet A through worksheet Z and worksheet AA through worksheetIV. The default value is A. For example, specifying WORKSHEET=B identifiesworksheet B from a group of worksheets.

The WORKSHEET statement is optional. The WORKSHEET statement is adatabase-description statement. It must follow the CREATE statement andprecede any editing statements when you create an access descriptor.

ACCESS Procedure Data Conversions for WKn Files

Use the Access procedure to define descriptors that identify spreadsheet data and theconversions necessary to use that data in SAS programs. The Lotus label data type isformatted as a SAS character type, and the 1-2-3 number data type is formatted as aSAS numeric type.

Fonts, attributes, and colors in the WKn files are not read into the SAS data sets.However, the ACCESS procedure supports most of the WKn number formats andautomatically converts them to the corresponding SAS formats. Any WKn data stringslonger than 200 characters are truncated while being converted into SAS data sets, andany SAS data file created from WKn files can contain only up to 256 variables and8,192 observations.

The following table shows the default SAS System variable formats that the ACCESSprocedure assigns to each type of WKn file numeric data include date and time values.

Page 252: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

244 DBLOAD Procedure: WKn Specifics � Chapter 16

Table 16.5 Default SAS System Variable Formats for WKn File Data

WKn File Data SAS Variable Format

Data Type Data FormatColumnWidth Decimal Number Type Format

Char** * w Char $w.

Numeric*** Default w Num BESTw.

Numeric AUTOMATIC w d Num BESTw.

Numeric FIXED w d Num w.d

Numeric SCIENTIFIC w d Num Ew.d

Numeric CURRENCY w d Num DOLLARw.d

Numeric PERCENT w d Num PERCENTw.d

Numeric COMMA w d Num COMMAw.d

Numeric GENERAL w Num BESTw.

Numeric DD-MON-YY w. Num DATE7.

Numeric DD-MON w Num DATE7.

Numeric MON-YY w Num MONYY5.

Numeric MM-DD-YY w Num MMDDYY8.

Numeric MM-DD w Num MMDDYY8.

Numeric HH-MM-SS w Num TIME8.

Numeric HH-MM-SS w Num TIME5.

Numeric HH-MM-SS AM/PM w Num TIME12.

Numeric HH-MM AM/PM w Num TIME9.

* Any valid Lotus 1–2–3 data format.** Label or formula string data.*** Number or formula data.

If WKn file fall outside of the valid SAS data ranges, you receive an error message inthe SAS log when you try to access the data.

The SAS/ACCESS interface does not fully support the Lotus1–2–3 hidden and textformats. WKn data in hidden format are displayed in SAS data sets. However, you candrop the hidden column when you are creating the access descriptor. If you want todisplay the formula in the text format, add a label prefix character to indicate that theformula entry is a label. Otherwise, the results of the formula are displayed.

DBLOAD Procedure: WKn SpecificsChapter 15, “The DBLOAD Procedure,” on page 219 contains general information

about this feature. This section provides WKn specific syntax for the DBLOADprocedure and describes DBLOAD procedure data conversions.

Page 253: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure Syntax for WKn Files 245

DBLOAD Procedure Syntax for WKn FilesTo create and load a WKn table, the SAS/ACCESS interface to WKn uses the

following statements:

PROC DBLOAD <DBMS=WK1|WK3|WK4><DATA= <libref.>SAS data-set>;

PATH=’path-and-filename<.WK1|.WK3|.WK4>’ | <’>filename<’> | fileref;PUTNAMES <=> YES | NO | Y | N;ACCDESC= <libref.>access-descriptor;DELETE variable-identifier-1 <…variable-identifier-n>;ERRLIMIT= error-limit;FORMAT SAS variable-name-1 SAS format-1 <=>

<…SAS variable-name-n SAS format-n>;LABEL;LIMIT= load-limit ;LIST <ALL | COLUMNS | FIELDS | variable-identifier>;RENAME variable-identifier-1 <=> <’>column-name-1<’>

<…variable-identifier-n = <’>column-name-n<’>>;RESET ALL | variable-identifier-1 <…variable-identifier-n>;

<…column-identifier-n <=> C | N>;WHERE SAS where-expression;LOAD;

RUN;

The QUIT statement is also available in the DBLOAD procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

This list provides detailed information about the WKn specific statements:

PUTNAMES <=> YES | NO | Y | N;writes column names to the first row of the new WKn file. The column names canbe default SAS variable names or, if you specify the LABEL statement, SASvariable labels. You can modify the column names using the RENAME statement.

The PUTNAMES statement is optional. If you omit PUTNAMES, data is readfrom the data set and written to the WKn file beginning in the first row of theWKn file, and no column names are written to the file.

You can change the default value to YES by setting the SS_NAMESenvironment variable. For more information, see “Setting Environment Variablesfor XLS Files” on page 240.

FORMAT SAS variable-name-1 SAS format-1 <SAS variable-name-n SAS format-n>;assigns a temporary format to a SAS variable in the input SAS data set. Thisformat temporarily overrides any other format for the variable. The assignmentlasts only for the duration of the procedure. Assign formats to as many variablesas you want in one FORMAT statement.

Use FORMAT when you want to change the format, column width, or thenumber of decimal digits for columns being loaded into the PC file. For example, ifyou change the SAS variable format 12.1 to DOLLAR15.2, the column format ofthe loaded data changes from a fixed numeric format with a column width of 12and one decimal digit to a currency format with a column width of 15 and twodecimal digits.

Page 254: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

246 DBLOAD Procedure Data Conversions for WKn Files � Chapter 16

DBLOAD Procedure Data Conversions for WKn FilesThis section explains how SAS data is read into Lotus 1-2-3 data when a table is

loaded. In this conversion, the SAS character data type is converted into the Lotus 1-2-3label type, and the SAS numeric type is converted into the Lotus 1-2-3 number type.

The SAS/ACCESS interface automatically converts SAS formats to the same orassociated Lotus 1-2-3 formats and column widths. However, you can temporarilyassign other formats and column widths to SAS variables by using the FORMATstatement. The following table shows SAS variable types and formats and the WKndata types, formats, and column widths that you can assign them to.

Note: The FORMAT statement in the DBLOAD procedure changes only the formatof SAS variables while you are creating and loading the WKn files. When the procedureis completed, the formats of SAS variables return to their original settings. �

Table 16.6 Converting SAS Variable Formats to WKn File Data

SAS Variable Format WKn File Data

Type Data Format Data Type Column FormatColumnWidth Number

Char $w. LABEL DEFAULT w

Char $CHARw. LABEL DEFAULT w

Num w.d NUMBER FIXED w d

Num Fw.d NUMBER FIXED w d

Num Ew.d NUMBER SCIENTIFIC w d

Num DOLLARw.d NUMBER CURRENCY w d

Num PERCENTw.d NUMBER PERCENT w d

Num COMMAw.d NUMBER COMMA w d

Num BESTw. NUMBER DEFAULT w

Num BESTw. NUMBER GENERAL w

Num DATE5. NUMBER DD-MON 7

Num DATE7. NUMBER DD-MON-YY 10

Num MONYY5. NUMBER MON-YY 7

Num MMDDYY5. NUMBER MM-DD 6

Num MMDDYY8. NUMBER MM-DD-YY 9

Num TIME5. NUMBER HH-MM-SS 6

Num TIME8. NUMBER HH-MM-SS 9

Num TIME9. NUMBER HH-MM AM/PM 9

Num TIME12. NUMBER HH-MM-SS AM/PM

12

Page 255: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Setting Environment Variables for WKn Files 247

Setting Environment Variables for WKn FilesYou can change the default behavior of the SAS/ACCESS interface by setting

environment variables in your SAS configuration file. You can set four SAS/ACCESSenvironment variables: SS_MISS NULLS, SS_MIXED, SS_NAMES, and SS_SCAN.Setting these variables in your SAS configuration file changes how the interface worksby default.

The configuration file omits these three environment variables by default, whichmeans their default values are NO.

SS_MISS NULLSBy default, the DBLOAD procedure loads Lotus @NA cell values for missingvalues. Use this option to specify a null cell value instead. If set, missing values ina SAS data set are displayed as blanks in the Lotus 1-2-3 table.

SS_MIXED YES | NOYES allows both Lotus 1-2-3 numeric and character data in a column to bedisplayed as SAS character data. The Lotus 1-2-3 numeric data is converted to itscharacter representation when its corresponding SAS variable type is defined ascharacter.

NO does not convert Lotus 1-2-3 numeric data in a column into SAS characterdata. Lotus 1-2-3 numeric data is read in as SAS missing values when itscorresponding SAS variable type is defined as character. NO is the default.

Setting the SS_MIXED environment variable changes the default value of theMIXED statement in the Access procedure.

SS_NAMES YES | NOYES in the Access procedure generates SAS variable names from column names inthe first row of the worksheet or the specified range of the worksheet and readsdata from the second row. YES in the DBLOAD procedure writes column namesusing SAS variable names or SAS variable labels to the first row of the new WKnfile, time reads data from the data set and writes it to the WKn file beginning withthe second row.

The Access procedure generates the SAS variable names VAR0, VAR1, VAR2,and so on. It reads data from the first row of the worksheet or a specified range.NO in the DBLOAD procedure reads the data from the data set and writes it tothe WKn file beginning with the first row.

Setting the SS_NAMES environment variable changes the default value of theGETNAMES= statement option in the Access procedure and the PUTNAMES=statement option in the DBLOAD procedure.Default: NO

SS_SCAN YES | NO|number-of-rowsYES scans the data type and format of rows in a worksheet or specified rangeafter skipping the number of rows specified in the SKIPROWS statement.SS_SCAN finds the most common Lotus 1-2-3 data type and format in order togenerate the default SAS data type and format. If a number of rows is specified,the Access procedure scans only the data type and format from the specified rows.

NO uses the type and format of the first row in a worksheet or specified range,after skipping the number of rows specified in SKIPROWS= option, to generatethe default SAS data type and format.Default: No

Number-of-rows scans only the type and format of the specified number of rows.Setting the number of rows is more efficient because data is read from only thespecified number of rows rather than the entire file.

Page 256: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

248 ACCESS Procedure: DBF Specifics (Windows) � Chapter 16

Setting the SS_SCAN environment variable changes the default value of theSCANTYPE= statement option in the Access procedure.

ACCESS Procedure: DBF Specifics (Windows)Chapter 14, “The ACCESS Procedure for PC Files,” on page 195 contains general

information about this feature. This section provides DBF-specific syntax for theACCESS procedure and describes ACCESS procedure data conversions.

ACCESS Procedure Syntax for DBF FilesTo create an access descriptor, use the DBMS=DBF option and the

database-description statement PATH= option. This PATH= option suppliesDBF-specific information to SAS and must immediately follow the CREATE statement.In addition to the database-description statement, you can use optional editingstatements when you create an access descriptor. These editing statements must followthe database-description statement.

The database-description statement is required only when you create accessdescriptors. Because the DBF information is stored in an access descriptor, you do notneed to repeat this information when you create view descriptors.

Note: The SAS/ACCESS interface cannot read DBF files that are encrypted.Therefore, you cannot define an access descriptor based on these files. �

The SAS/ACCESS interface to DBF supports the following procedure statements:

PROC ACCESS options;CREATE libref.name.ACCESS|VIEW;UPDATE libref.name.ACCESS|VIEW;

PATH= ’path-and-filename<.DBF>’|<’>filename<’>| fileref;ASSIGN | AN <=> YES | NO;DROP <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;FORMAT <’>column-identifier-1<’><=>SAS format-name-1

<…<’>column-identifier-n<’> <=>SAS format-name-n>;LIST <ALL | VIEW | <’>column-identifier<’>>;RENAME <’>column-identifier-1<’><=>SAS variable-name-1

<…<’>column-identifier-n<’><=>SAS variable-name-n>;RESET ALL | <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;SELECT ALL | <’>column-identifier-1< ’> <…<’>column-identifier-n<’>>;SUBSET selection criteria;UNIQUE <=> YES | NO;

RUN;

The QUIT statement is also available in the Access procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

This example creates an access descriptor and a view descriptor based on DBF filedata.

options linesize=80;LIBNAME dbfliba ’SAS data-library’;

Page 257: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure Syntax for DBF Files 249

LIBNAME dbflibv ’SAS data-library’;

proc access dbms=dbf;/* create access descriptor */

create adlib.custs.access;path=’c:\dbfiles\dbcusts.dbf’;assign=yes;rename customer = custnum;format firstorder date9.;list all;

/* create usacust view */create vlib.usacust.view;select customer state zipcode name

firstorder;run;

ACCESS Procedure Data Conversions for DBF FilesThe table below shows the default SAS variable formats that the ACCESS procedure

assigns to each DBF file data type. If DBF file data falls outside of the valid SAS dataranges, you get an error message in the SAS log when you try to read the data.

Table 16.7 Default SAS Variable Formats for DBF File Data Types

DBF File Data Type SAS Variable Format

Character(n) $n. (n <= 200)

$200. (n > 200)

Numeric(N,n) (N,n)

Float(N,n)* (N,n)

Date MMDDYY8.

Logical $1.

* This data type applies to dBASE V and later. Check with other software products’ documentationto determine whether this data type applies.

DBLOAD Procedure: DBF Specifics (Windows)Chapter 15, “The DBLOAD Procedure,” on page 219 contains general information

about this feature. This section provides DBF-specific syntax for the DBLOADprocedure and describes DBLOAD procedure data conversions .

DBLOAD Procedure Syntax for DBF FilesTo create and load a DBF table, SAS/ACCESS Interface to PC Files uses the

following statements:

PROC DBLOAD <DBMS=DBF> <DATA=<libref.>SAS data-set>;PATH=’path-and-filename<.DBF>’ | <’>filename<’>|fileref;

Page 258: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

250 DBLOAD Procedure Syntax for DBF Files � Chapter 16

VERSION= dBASE-product-number;ACCDESC=<libref.>access-descriptor;DELETE variable-identifier-1 <…variable-identifier-n>;ERRLIMIT= error-limit;LABEL;LIMIT= load-limit;LIST <ALL | FIELDS | variable-identifier>;LOAD;RENAME variable-identifier-1= <’>database-field-name-1<’>

<…variable-identifier-n = <’>database-field-name-n<’>>;RESET ALL | variable-identifier-1 <…variable-identifier-n>;TYPE variable-identifier-1=’database-field-type-1’

<…variable-identifier-n = ’database-field-type-n’>;WHERE SAS where-expression;

RUN;

The QUIT statement is also available in PROC DBLOAD. However, it causes theprocedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the DBF-specific statements:

VERSION= dBASE-product-numberspecifies the number of the dBASE product you are using, such as dBASE IV. ThedBASE-product-number argument can be one of the following values: II, III, IIIP,IV, V, 2, 3, 3P, 4, and 5.

Specify VERSION= before the TYPE statement in order to get the correct datatypes for your new DBF table.Default: V

TYPE variable-identifier-1 = ’database-field-name-1’<… variable-identifier-n = ’database-field-name-n’>

specifies a DBF file data type, which is based on the SAS variable format. Thedatabase field name must be enclosed in quotation marks.

This example defines the data types for several database fields. You can specify thelength of the data type.

proc dbload dbms=dbf data=employee;path=’c:\sasdemo\employee.dbf’;rename firstname = fname;type empid = ’numeric(6)’

hiredate = ’date’salary = ’numeric(10,2)’jobcode = ’numeric(5)’;

run;

This next example creates a new DBF table, Exchange.Dbf, from the data fileDLib.RateOfex. An access descriptor DbFliba.Exchange is also created based on thenew table. You must be granted the appropriate privileges to create new DBF tables.

LIBNAME dbfliba ’SAS data-library’;LIBNAME dbflibv ’SAS data-library’;

proc dbload dbms=dbf data=dlib.rateofex;path=’c:\dbfiles\sasdemo\exchange.dbf’;

Page 259: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure Syntax for DBF Files 251

accdesc=adlib.exchange;rename fgnindol=fgnindolar 4=dolrsinfgn;type country=’char(25)’;load;

run;

Page 260: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

252 DBLOAD Procedure Data Conversions for DBF Files � Chapter 16

DBLOAD Procedure Data Conversions for DBF FilesThe following table shows the default DBF file data types that the DBLOAD

procedure assigns to each SAS variable format.

Table 16.8 Default DBF File Data Types for SAS Variable Formats

SAS Variable Formats DBF File Data Types

$w. CHAR(n)

w. NUMERIC

w.d. NUMERIC

datetimew.d DATE

datew. DATE

ew. FLOAT

binaryw. NUMERIC

Setting Environment Variables for DBF FilesMissing numeric values are filled in with nines by default. The DBFMISCH

environment variable is used to change the default by specifying the character that theinterface to DBF files uses to fill missing numeric fields. For example, if you try towrite a SAS file with a missing numeric variable to a DBF file, the corresponding fieldin the DBF file would be filled with the DBFMISCH character. Conversely, any numericor float field in a DBF file that is filled with the DBFMISCH character is treated asmissing when read by SAS.

You set the DBMISCH environment variable in the SAS configuration file using thefollowing syntax:

-set DBFMISCH value

Valid values are

<any single character>Type in any single character. For example, to fill missing numeric valueswith the zero character (0), enter -set DBFMISCH 0.

NULLSTo replace missing numeric values with binary zeros, enter -set DBFMISCH NULLS.

BLANKSTo replace missing numeric values with blanks, enter -set DBFMISCH BLANKS.

ACCESS Procedure: DIF Specifics

Chapter 14, “The ACCESS Procedure for PC Files,” on page 195 contains generalinformation about this feature. This section provides DIF-specific syntax for theACCESS procedure and describes ACCESS procedure data conversions..

Page 261: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � ACCESS Procedure Syntax for DIF Files 253

ACCESS Procedure Syntax for DIF FilesTo create an access descriptor, use the DBMS=DIF option and the

database-description statements PATH=, DIFLABEL=, and SKIPROWS=. Thesestatements supply DIF-specific information to SAS, and must immediately follow theCREATE statement. In addition to the database-description statements, you can useoptional editing statements when you create an access descriptor. These editingstatements must follow the database-description statements.

Database-description statements are required only when you create accessdescriptors. Because the DIF information is stored in an access descriptor, you do notneed to repeat this information when you create view descriptors.

The SAS/ACCESS interface to DIF uses the following procedure statements:

PROC ACCESS options;CREATE <libref.>member-name.ACCESS | VIEW;

UPDATE <libref.>member-name.ACCESS | VIEW;

PATH= ’path-and-filename<.DIF>’ | <’>filename<’>| fileref;DIFLABEL;SKIPROWS <=> number-of-rows-to-skip;ASSIGN | AN <=> YES | NO;DROP <’>column-identifier-1<’><…<’>column-identifier-n<’>>;FORMAT <’>column-identifier-1<’><=>SAS format-name-1

<…<’>column-identifier-n<’><=> SAS format-name-n>;LIST <ALL | VIEW | <’>column-identifier<’>>;RENAME <’>column-identifier-1<’> <=> SAS variable-name-1

<…<’>column-identifier-n<’> <=> SAS variable-name-n>;RESET ALL | <’>column-identifier-1<’><…<’>column-identifier-n<’>>;SELECT ALL | <’>column-identifier-1<’> <…<’>column-identifier-n<’>>;SUBSET selection criteria ;TYPE <’>column-identifier-1<’><=> C | N

<…column-identifier-n <=> C | N>;UNIQUE <=> YES | NO;

RUN;

The QUIT statement is also available in the Access procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the DIF-specific statements:

DIFLABELindicates whether variable names are generated from the first row of the columns.If you omit this statement, variable names that are generated are based on thecolumns’ placement in the first row. That is, SAS labels each column as COL0,COL1, COL2, and so on. These labels become the names of SAS variables in theaccess descriptor.

If you specify DIFLABEL=, the ACCESS procedure reads column labels fromthe first row of the DIF file and uses them as the SAS variable names in theaccess descriptor. You provide the DIF file column labels; they are not the letters

Page 262: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

254 ACCESS Procedure Syntax for DIF Files � Chapter 16

(for example, A, B, and so on) that identify the columns in a worksheet. If youspecify DIFLABEL , the SKIPROWS= statement automatically changes to 1.

Always specify DIFLABEL statement after the PATH= statement and beforeany editing statements. When you update a descriptor, you are not allowed tospecify the DIFLABEL= statement.

Create an Access Descriptor and a View Descriptor Based on DIF file data.

options linesize=80;LIBNAME difdliba ’SAS data-library’;LIBNAME diflibv ’SAS data-library’;

proc access dbms=dif;/* create access descriptor */create difliba.custs.access;path=’c:\difiles\dbcusts.dif’;diflabel;skiprows=2;assign=yes;rename customer = custnum;format firstorder date9.;list all;

/* create usacust view */create diflibv.usacust.view;select customer state zipcode name

firstorder;run;

SKIPROWS <=> number-of-rows-to-skip;specifies the number of rows, beginning at the top of the DIF file, to ignore whenyou read data from the file. The default value for SKIPROWS is 0. The skipped(or ignored) rows often contain information such as column labels or names, orunderscores rather than input data.

If you specify the DIFLABEL statement, the default value of SKIPROWSautomatically changes to 1. The SKIPROWS statement should always follow thePATH= statement and precede any editing statements when you are creating adescriptor. The first row of data after SKIPROWS is used to generate the SASvariable types and formats. If there is no data in the first row of a column afterSKIPROWS, the data in the rest of the column is assumed to be character data,even if the data in the next row is numeric.

Any data value in a column that does not match the type is treated as a missingvalue. However, if you set the DIFNUMS environment variable to YES in your SASconfiguration file, any numeric data values in a character column are converted tothe character representation of the number and are not treated as missing values.Add the following line to your SAS configuration file to set the Default:DIFNUMS= environment variable to YES:

-SET DIFNUMS YES

The default value for the DIFNUMS environment variable is NO.You can change the column type from the default type that the Access procedure

defines when you create an access descriptor.Note: Refer to the SAS documentation for your operating environment for more

information about environment variables.

Page 263: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � DBLOAD Procedure: DIF Specifics 255

ACCESS Procedure Data Conversions for DIF FilesThe following table shows the default SAS variable formats that the ACCESS

procedure assigns to each type of DIF file data. DIF file numeric data includes date andtime values.

Table 16.9 Default SAS Variable Formats for DIF File Data

DIF File Data SAS Variable Format

C (Character) $20.

N (Numeric) 15.2

If DIF file data falls outside of the valid SAS data ranges, you get an error messagein the SAS log when you try to read the data.

Datetime Conversions in the ACCESS ProcedureWhen you create an access descriptor, SAS cannot distinguish a Lotus datetime value

from other numeric data. SAS stores the Lotus datetime value as a number anddisplays it like other Lotus numeric data by using the SAS variable format 15.2 (thedefault format for this interface).

To convert a Lotus datetime value to a SAS datetime value, you must specify a SASdatetime format in the access descriptor. A Lotus datetime value is a number thatrepresents the number of days between January 1, 1900, and a specified date; changingthe default SAS format (15.2) to a datetime format in the descriptor causes the Lotusvalue to be converted to an equivalent SAS datetime value based on January 1, 1960.In other words, the Lotus numeric value for January 1, 1960 (which is 21,916) isconverted to the equivalent SAS representation of January 1, 1960 (which is 0) only if aSAS datetime format is stored in the descriptor for that column. Otherwise, the Lotusvalue of 21,916 is treated as a SAS numeric value of 21,916.

The following table shows how SAS uses a Lotus datetime value to convert to a SASdatetime format.

Table 16.10 Value-to-Format Conversions

For a SAS format SAS uses

date integer portion of the Lotus number

time decimal portion of the Lotus number

date-and-time integer and decimal portion of the Lotus number

DBLOAD Procedure: DIF SpecificsChapter 15, “The DBLOAD Procedure,” on page 219 contains general information

about this feature. This section provides DIF-specific syntax for the DBLOADprocedure and describes DBLOAD procedure datetime conversions.

Page 264: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

256 DBLOAD Procedure Syntax for DIF Files � Chapter 16

DBLOAD Procedure Syntax for DIF FilesTo create and load a DIF table, SAS/ACCESS Interface to PC Files uses the following

statements.

PROC DBLOAD DBMS=DIF <DATA=<libref.>SAS data-set>;PATH=’path-and-filename<.DIF>’ | <’>filename<’>| fileref;DIFLABEL;ACCDESC=<libref.>access-descriptor;DELETE variable-identifier-1 <…variable-identifier-n>;ERRLIMIT=error-limit;FORMAT SAS variable-name-1 SAS format-1 <…SAS variable-name-n SAS

format-n>;LABEL;LIMIT=load-limit;LIST <ALL | COLUMNS | FIELDS | variable-identifier>;LOAD;RENAME variable-identifier-1= <’>column-name-1<’>

<…variable-identifier-n=<’>column-name-n<’>>;RESET ALL | variable-identifier-1 <…variable-identifier-n>;WHERE SAS where-expression;

RUN;

The QUIT statement is also available in the DBLOAD procedure. However, it causesthe procedure to terminate. QUIT is used most often in the interactive line and batchmodes to exit the procedure without exiting SAS.

The following list provides detailed information about the DIF-specific statements:

DIFLABELwrites column labels to the first row of the new DIF file and follows the columnlabels with a blank row. The column labels can be default SAS variable names or,if you specify the LABEL statement, SAS labels. You can modify the column labelsusing the RENAME statement.Note: If this statement is omitted, data is read from the data set and written to

the DIF file beginning in the first row of the DIF file, and no column labels arewritten to the file.

FORMAT SAS variable-name-1 SAS format-1< …SAS variable-name-n SASformat-n>;

assigns a temporary format to a SAS variable in the input SAS data set. Thisformat temporarily overrides any other format for the variable. The assignmentlasts only for the duration of the procedure. Assign formats to as many variablesas you want in one FORMAT statement.

Use FORMAT when you want to change the format, column width, or thenumber of decimal digits for columns being loaded into the PC file. For example, ifyou change the SAS variable format 12.1 to DOLLAR15.2, the column format ofthe loaded data changes from a fixed numeric format with a column width of 12and one decimal digit to a currency format with a column width of 15 and twodecimal digits.

This example creates a new DIF table, Exchange.dif, from the data file Dlib.RateOfex.An access descriptor AdLib.Exchange is also created based on the new DIF table. Youmust be granted the appropriate privileges in order to create new DIF files.

Page 265: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

File-Specific Reference � Setting Environment Variables for DIF Files 257

LIBNAME difdliba ’SAS data-library’;LIBNAME diflibv ’SAS data-library’;

proc dbload dbms=dif data=dlib.rateofex;accdesc=adlib.exchange;path=’c:\difiles\sasdemo\exchange.dif’;diflabel;rename fgnindol=fgnindolar 4=dolrsinfgn;load;

run;

Datetime Conversions in the DBLOAD Procedure

If a SAS variable is specified with a date, time, or datetime format in the FORMATstatement, the interface view engine converts that datetime value into the equivalentLotus datetime value when the new DIF file is created. However, the DIF file has noway of relating this formatting information to Lotus products. Therefore, when you loadthe DIF file into a Lotus 1-2-3 worksheet, the datetime values are represented asnumbers. You should assign (from within Lotus) a Lotus datetime format to anydatetime column that you load from a DIF file.

If a SAS variable represents a date, time, or datetime value, but it has not beenassigned a SAS datetime format — the SAS datetime value is represented as anumber — the number is not converted into an equivalent Lotus datetime value in theDIF file. Rather, the number is written to the new DIF file as is. Because SAS datesare based on January 1, 1960, and Lotus dates are based on January 1, 1900, if youassign a Lotus datetime format to an unconverted Lotus column, the datetime values inthat column are inaccurate.

Use the DBLOAD FORMAT statement to maintain a SAS variable format in theinput data set yet change it only while the DBLOAD procedure is in progress. You canuse this statement to assign a temporary format to a SAS variable for the duration ofthe procedure without affecting how SAS stores the variable.

For example, if the SAS format for the BirthDat variable in the MyData.SasEmpsdata set is left at the default 15.2 format, you can specify the FORMAT statement tochange the variable’s format to DATE7. while you are creating and loading the DIF file.When you load the DIF file into a Lotus 1-2-3 worksheet, you can specify an equivalentLotus date format. When the DBLOAD procedure has completed, the SAS format forthe BirthDat variable reverts to the 15.2 format.

You can specify the FORMAT statement in the DBLOAD procedure statement whenyou invoke the procedure using any of the methods of processing.

Note: There are certain display restrictions on the SAS datetime values that areloaded into Lotus 1-2-3 worksheets through DIF files. If you load a SAS variable with aDATETIMEw.d format into a DIF file, Lotus stores the number with both integer anddecimal portions. However, when you load the DIF file into a Lotus 1-2-3 worksheetand specify a format for the column, you can specify only a date format (that uses theinteger portion) or time format (that uses the decimal portion) for that column, not bothat the same time. �

Setting Environment Variables for DIF Files

Page 266: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

258 DIF File Data Types � Chapter 16

DIF File Data TypesBy default, any data value in a column that does not match the type is treated as a

missing value. However, if you set the DIFNUMS environment variable to YES in yourSAS configuration file, any numeric data values in a character column are converted tothe character representation of the number and are not treated as missing values. Addthe following line to your SAS configuration file to set the DIFNUMS environmentvariable to YES:

-SET DIFNUMS YES

The default for the DIFNUMS environment variable is NO. Refer to the SASCompanion for your operating system for more information about environmentvariables.

You can change the column type from the type that SAS/ACCESS determines whenyou create an access descriptor.

Page 267: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

259

P A R T6

Appendixes

Appendix 1. . . . . . . . .The DBF and DIF Procedures 261

Appendix 2. . . . . . . . .Recommended Reading 267

Page 268: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

260

Page 269: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

261

A P P E N D I X

1The DBF and DIF Procedures

Introduction to the DBF and DIF Procedures 261Overview: DBF and DIF Procedures 261

Introduction to the DBF and DIF Procedures

Overview: DBF and DIF ProceduresThe DBF and DIF procedures give UNIX, Microsoft Windows, and IBM z/OS users an

alternative way to access DBF and DIF files. Instead of creating access descriptors andview descriptors, you can convert these PC file types to SAS data sets, or vice versa.

Under UNIX and Microsoft Windows operating environments, you can use the DBFand DIF procedures to convert a DBF or DIF file to a SAS data set or to convert a SASdata set to a DBF or DIF file. Under IBM z/OS, only the DBF procedure is available.

See: “Methods for Accessing PC Files Data” on page 3 for the other methods foraccessing data in PC file formats under UNIX, and Microsoft Window operatingenvironments.

The DBF Procedure

Converts a dBASE file to SAS data set or a SAS data set to a dBASE file.

SyntaxPROC DBF options;

PROC DBF Options

DB2|DB3|DB4|DB5=fileref | filenamespecifies the fileref or filename of a DBF file. The DBn option must correspond to theversion of dBASE with which the DBF file is compatible. You specify the version withthe DBn option, where n is the version number and can have a value of 2, 3, 4, or 5.

Page 270: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

262 The DBF Procedure � Appendix 1

If you specify a fileref, the FILENAME statement that you used to define it mustspecify the filename plus a .dbf extension. For example, filename myref ’/my_dir/myfile.dbf’.

If you specify a filename instead of a fileref, you can specify only the name itself(omitting the .dbf extension), and the file must be in the current directory. Forexample, this PROC DBF statement creates the EMP.DBF file (with the name inuppercase) from the MyLib.Employee data set:

proc dbf db5=emp data=mylib.employee;

You cannot specify emp.dbf or a full pathname (proc dbf db5=’/my/unix_directory/emp.dbf’).

The DBn= option is required.

DATA=<libref.>membernames the input SAS data set. Use this option if you are creating a DBF file from aSAS data set. If you use the DATA= option, do not use the OUT= option. If you omitthe DATA= option, SAS software creates an output SAS data set from the DBF file.

OUT=<libref.>membernames the SAS data set that is created to hold the converted data. Use this optiononly if you are creating a SAS data set from a DBF file and you did not specify theDATA= option.

If OUT= is omitted, SAS creates a temporary data set in the Work library. (UnderUNIX and IBM z/OS, the temporary data set is named Data1 [...Datan]. UnderMicrosoft Windows, it is called _DATA_.) If OUT= is omitted or if you do not specify atwo-level name in the OUT= option, the data set remains available during yourcurrent SAS session, but it is not permanently saved.

Details

The DBF procedure converts dBASE files to SAS data sets that are compatible with thecurrent release of SAS, or it converts SAS data sets to DBF files.

PROC DBF produces one output file but no printed output. The output file containsthe same information as the input file but in a different format.

The DBF procedure works with DBF files that all current versions and releases ofdBASE (II, III, III PLUS, IV, and 5.0) create and with most DBF files that othersoftware products create.

Future versions of dBASE files might not be compatible with the current version ofthe DBF procedure. To use the DBF procedure, you must have a SAS/ACCESSInterface to PC Files license.

Converting DBF Fields to SAS VariablesNumeric variables are stored in character form by DBF files. These numeric variablesbecome SAS numeric variables when converted from a DBF file to a SAS data set. If aDBF numeric value is missing, the corresponding dBASE numeric field is filled with thecharacter 9, by default.

Character variables become SAS character variables. Logical fields become SAScharacter variables with a length of 1. Date fields become SAS date variables. Whenyou are converting a DBF file to a SAS data set, fields with data stored in auxiliaryDBF files (Memo and General fields) are ignored.

When a dBASE II file is translated into a SAS data set, any colons in dBASEvariable names are changed to underscores in SAS variable names. Conversely, when aSAS data set is translated into a dBASE file, any underscores in SAS variable namesare changed to colons in dBASE field names.

Page 271: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBF and DIF Procedures � The DBF Procedure 263

Converting SAS Variables to DBF FieldsNumeric variables are stored in character form by DBF files. SAS numeric variablesbecome numeric variables with a length of 16 when converting from a SAS data set to aDBF file. A SAS numeric variable with a decimal value must be stored in a decimalformat in order to be converted to a DBF numeric field with a decimal value. In otherwords, unless you associate the SAS numeric variable with an appropriate format in aSAS FORMAT statement, the corresponding DBF field does not have any value to theright of the decimal point. You can associate a format with the variable in a SAS dataset when you create the data set or by using the DATASETS procedure.

If the number of digits—including a possible decimal point—exceeds 16, a warningmessage is issued and the DBF numeric field is filled with the character 9. All SAScharacter variables become DBF fields of the same length. When you are convertingdata from a SAS data set to a DBF file that is compatible with dBASE III or later, SASdate variables become DBF date fields. When you are converting data from a SAS dataset to a dBASE II file, SAS date variables become dBASE II character fields in the formYYYYMMDD.

Transferring Other Software Files to DBF FilesYou might find it helpful to save another software vendor’s file to a DBF file and thenconvert that file into a SAS data set. UNIX users find this especially helpful. Forexample, you could save an Excel XLS file to a DBF file (by selecting File � Save Asfrom within an Excel spreadsheet and selecting the Emp.dbf file) and then use PROCDBF to convert that file into a SAS data set. Or you could do the reverse: use PROCDBF to convert a SAS data set into a DBF file and then load that file into an Excelspreadsheet.

Examples for UNIX

Example 1: Example 1: Converting a dBASE II File to a SAS Data Set In this example,a dBASE II file named Employee.dbf is converted to a SAS data set. Because noFILENAME statement is specified, the last level of the filename is assumed to be .dbfand the file is assumed to be in your current directory and in uppercase.

LIBNAME save ’/my/unx_save_dir’;proc dbf db2=employee out=save.employee;run;

Example 2: Example 2: Converting a SAS Data Set to a dBASE 5 File In this example,a SAS data set is converted to a dBASE 5 file. A FILENAME statement specifies afileref that names the dBASE 5 file. You must specify the FILENAME statement beforethe PROC DBF statement.

LIBNAME mylib ’/my/unix_directory’;filename employee ’/sasdemo/employee.dbf’;proc dbf db5=employee data=mylib.employee;run;

Here is the same example for the Microsoft Windows environment:

LIBNAME mylib ’c:\my\directory’;filename employee ’c:\sasdemo\employee.dbf’;proc dbf db5=employee data=mylib.employee;run;

Here is the same example for the IBM z/OS environment:

Page 272: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

264 The DIF Procedure � Appendix 1

LIBNAME mylib ’sasdemo.employee.data’;filename dbfout ’sasdemo.newemp.dbf’ recfm=n;proc dbf db5=dbfout data=mylib.employee;run;

The DIF Procedure

Converts a DIF file to SAS data set or a SAS data set to a DIF file.

Restrictions: The DIF procedure is available only under UNIX and Microsoft Windowsoperating environments.

SyntaxPROC DIF options;

PROC DIF Options

DIF=fileref | filenamespecifies the fileref or filename of a DIF file.

If you specify a fileref, the FILENAME statement that you used to define it mustspecify the filename plus a .dif extension. For example, filename myref ’/my_dir/myfile.dif’.

If you specify a filename instead of a fileref, you can specify only the name itself(omitting the .dif extension) and the file must be in the current directory. Forexample, this PROC DIF statement creates the Emp.dif file from theMyLib.Employee data set:

proc dif dif=emp data=mylib.employee;

You cannot specify emp.dif or a full pathname (proc dif dif=’/my/unix_directory/emp.dif’).

DATA=<libref.>membernames the input SAS data set. Use this option if you are creating a DIF file from aSAS data set. If you use this option, do not use the OUT= option. If you omit theDATA= option, SAS creates an output SAS data set from the DIF file.

OUT=<libref.>membernames the SAS data set to hold the converted data. You use this option only if youomit the DATA= option and you are creating a SAS data set from a DIF file.

If OUT= is omitted, SAS creates a temporary data set in the Work library. (UnderUNIX, the temporary data set is named Data1 [...Datan]. Under Microsoft Windows,it is called _DATA_. If OUT= is omitted or if you do not specify a two-level name inthe OUT= option, the data set remains available during your current SAS sessionbut is not permanently saved.

LABELScauses PROC DIF to write the names of the SAS variables as the first row of the DIFfile and a row of blanks as the second row of the DIF file. The actual data portion ofthe DIF file begins in the third row. The LABELS option is allowed only when youare converting a SAS data set to a DIF file.

Page 273: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

The DBF and DIF Procedures � The DIF Procedure 265

PREFIX=namespecifies a prefix to be used in constructing SAS variable names when you areconverting a DIF file to a SAS data set. For example, if PREFIX=VAR, the newvariable names are VAR1, VAR2, ... VARn. If you omit the PREFIX= option, PROCDIF assigns the names Col1, Col2, ... Coln.

SKIP=nspecifies the number of rows, beginning at the top of the DIF file, to be ignored whenconverting a DIF file to a SAS data set. For example, the first row of your DIF filecontains column headings and the second row of your DIF file is a blank row. Theactual data in your DIF file begins in row 3. You should specify SKIP=2 so thatPROC DIF ignores the nondata portion of your DIF file. You could also delete thefirst two rows of your DIF file before using PROC DIF.

DetailsThe DIF procedure converts data interchange format (DIF) files to SAS data sets thatare compatible with the current release of SAS software, or it converts SAS data sets toDIF files.

PROC DIF produces one output file but no printed output. The output file containsthe same information as the input file but in a different format.

Software Arts, Inc. developed the data interchange format to be used as a commonlanguage for data. Originally, DIF was made popular by products such as Lotus 1-2-3and VisiCalc. Although DIF is not as popular today as it once was, it is still supportedby many software products.

Note: Any DIF file that you plan to convert to a SAS data set should be in a tabularformat. All items in a given column should represent the same type of data. If any rowsin the DIF file contain inconsistent data—for example, a row of underscores, dashes, orblanks—delete these rows before converting the DIF file to a SAS data set. It isrecommended that you make a backup copy of your DIF table before you make thesemodifications. �

When you are converting data from a DIF file to a SAS data set, each row of the DIFfile becomes an observation in the SAS data set. Conversely, when you are converting aSAS data set to a DIF file, each SAS observation becomes a row in the DIF file. To usethe DIF procedure, you must have a SAS/ACCESS Interface to PC Files license.

Converting DIF Variables to SAS VariablesCharacter variables in a DIF file (sometimes referred to as string values) become SAScharacter variables of length 20. If a DIF character variable’s value is longer than 20characters, it is truncated to a length of 20 in the SAS output data set. The quotationmarks that normally enclose character variable values in a DIF file are removed whenthe value is converted to a SAS character value.

Numeric variables, which can be represented in either integer or scientific notation ina DIF file, become SAS numeric variables when a DIF file is converted to a SAS data set.

Transferring SAS Data Sets to and from Other Software Products Using DIFDIF files are not generally used as the native file format for a software product’s datastorage. Therefore, transferring data between SAS and another software product is atwo-step process when using DIF files.

To send SAS data sets to another software product using DIF files, you must first runPROC DIF to convert your SAS data set to a DIF file. Use whatever facility is providedby the target software product to read the DIF file. For example, you use the

Page 274: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

266 The DIF Procedure � Appendix 1

Lotus 1-2-3 Translate Utility to translate a DIF file to a 1-2-3 worksheet file. (Thisfacility might be provided by an import tool or from an Open window in that softwareproduct.) After the application reads the DIF file data, the data can be manipulatedand saved in the application’s native format.

To transfer data in the opposite direction — from a software product to a SAS dataset — the process is reversed. First, export the data to a DIF file and then run PROCDIF to read the DIF file into a SAS data set.

Missing ValuesThe developers of the data interchange format (DIF) files suggest that you treat allnumeric values that have a value indicator other than V as missing values. PROC DIFfollows this convention. When a DIF file is converted to a SAS data set, any numericvalue with a value indicator other than V becomes a SAS missing value.

When a SAS data set that has missing values for some numeric variables isconverted to a DIF file, the following assignments are made in the DIF file for thevariables with missing values:

� the type indicator field value is set to 0

� the number field value contains a string of 16 blanks� the value indicator is set to NA.

Examples

Example 1: Example 1: Converting a DIF File to a SAS Data Set In this example, aDIF file named Employee.dif is converted to a SAS data set. Because no FILENAMEstatement is specified, the last level of the filename is assumed to be .dif, and the file isassumed to be in your current directory and in uppercase.

LIBNAME save ’/my/my_unx_dir’;proc dif dif=employee out=save.employee;run;

Example 2: Example 2: Converting a SAS Data Set to a DIF File In this example, aSAS data set is converted to a DIF file. A FILENAME statement is used to specify afileref that names the DIF file. You must specify the FILENAME statement before thePROC DIF statement.

filename employee ’c:\sasdemo\employee.dif’;proc dif dif=employee data=save.employee;run;

Here is the same example in a UNIX environment:

filename employee ’/sasdemo/employee.dif’;proc dif dif=employee data=save.employee;run;

See Also“Programmer’s Guide to the DIF,” Software Arts Technical Notes (SATN-18).

Page 275: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

267

A P P E N D I X

2Recommended Reading

Recommended Reading 267

Recommended Reading

Here is the recommended reading list for this title:� SAS/ACCESS for Relational Databases: Reference� SAS Language Reference: Concepts

� SAS Language Reference: Dictionary� SAS Macro Language: Reference� Base SAS Procedures Guide

� SAS Companion that is specific to your operating environment

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

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

Customers outside the United States and Canada, please contact your local SAS officefor assistance.

Page 276: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

268

Page 277: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

269

Glossary

This glossary defines SAS software terms that are used in this document as well asterms that relate specifically to SAS/ACCESS software.

access descriptora SAS/ACCESS file that describes data that a data management system manages.After creating an access descriptor, you can use it as the basis for creating one ormore view descriptors. See also view and view descriptor.

browsing datathe process of viewing the contents of a file. Depending on how the file is accessed,you can view SAS data either one observation (row) at a time or as a group in atabular format. You cannot update data that you are browsing.

bulk loadto load large amounts of data into a database object, using methods that are specificto a particular DBMS. Bulk loading enables you to rapidly and efficiently addmultiple rows of data to a table as a single unit.

client(1) a computer or application that requests services, data, or other resources from aserver. (2) in the X Window System, an application program that interacts with the Xserver and can perform tasks such as terminal emulation or window management.For example, SAS is a client because it requests windows to be created, results to bedisplayed, and so on.

columnin relational databases, a vertical component of a table. Each column has a uniquename, contains data of a specific type, and has certain attributes. A column isanalogous to a variable in SAS terminology.

column functionan operation that is performed for each value in the column that is named as anargument of the function. For example, AVG(SALARY) is a column function.

committhe process that ends a transaction and makes permanent any changes to thedatabase that the user made during the transaction. When the commit processoccurs, locks on the database are released so that other applications can access thechanged data. The SQL COMMIT statement initiates the commit process.

DATA step view

Page 278: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

270 Glossary

a type of SAS data set that consists of a stored DATA step program. Like other SASdata views, a DATA step view contains a definition of data that is stored elsewhere;the view does not contain the physical data. The view’s input data can come from oneor more sources, including external files and other SAS data sets. Because a DATAstep view only reads (opens for input) other files, you cannot update the view’sunderlying data.

data typean attribute of every column in a table or database. The data type tells the operatingsystem how much physical storage to set aside for the column and specifies what typeof data the column will contain. It is similar to the type attribute of SAS variables.

data valuein SAS software, a unit of character or numeric information in a SAS data set. Adata value represents one variable in an observation.

databasean organized collection of related data. A database usually contains named files,named objects, or other named entities such as tables, views, and indexes.

database fielda vertical component of a dBASE .DBF file that contains data of a specific type withcertain attributes. A database field is analogous to a variable in SAS terminology.

database filea two-dimensional system of representing data in records and fields.

database management system (DBMS)a software application that enables you to create and manipulate data in the form ofdatabases. See also relational database management system.

editing datathe process of viewing the contents of a file with the intent and the ability to changeits data. Depending on how the file is accessed, you can view the details either oneobservation at a time or in a tabular format.

enginea component of SAS software that reads from or writes to a file. Each engine enablesSAS to access files that are in a particular format. There are several types of engines.

filea collection of related records that are treated as a unit. SAS files are processed andcontrolled through SAS software and are stored in SAS libraries.

formatan instruction that SAS uses to display or write each value of a variable (or column).Some formats are supplied by SAS software. You can create other formats by usingthe FORMAT procedure in Base SAS software. In SAS/ACCESS software, the defaultformats vary according to the interface product.

indexin SAS software, a component of a SAS data set that enables SAS to accessobservations in the SAS data set quickly and efficiently. The purpose of SAS indexesis to optimize WHERE-clause processing and to facilitate BY-group processing.

informata pattern or set of instructions that SAS uses to determine how data values in aninput file should be interpreted. SAS provides a set of standard informats and alsoenables you to define your own informats.

interface view engine

Page 279: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Glossary 271

a SAS engine that is used by SAS/ACCESS software to retrieve data from files thathave been formatted by another vendor’s software. Each SAS/ACCESS interface hasits own interface view engine, which reads the interface product data and returns thedata in a form that SAS can understand (that is, in a SAS data set). SASautomatically uses an interface view engine; the engine name is stored inSAS/ACCESS descriptor files so that you do not need to specify the engine name in aLIBNAME statement.

librefa name that is temporarily associated with a SAS library. The complete name of aSAS file consists of two words, separated by a period. The libref, which is the firstword, indicates the library. The second word is the name of the specific SAS file. Forexample, in VLIB.NEWBDAY, the libref VLIB tells SAS which library contains thefile NEWBDAY. You assign a libref with a LIBNAME statement or with an operatingsystem command.

membera name that represents a particular data item within a dimension. For example,September 1996 might be a member of the Time dimension. A member can be eitherunique or non-unique. For example, 1997 and 1998 represent unique members in theYear level of a Time dimension. January represents non-unique members in theMonth level, because there can be more than one January in the Time dimension ifthe Time dimension contains data for more than one year.

member namea name that is assigned to a SAS file in a SAS library.

member typea SAS name that identifies the type of information that is stored in a SAS file.Member types include ACCESS, DATA, CATALOG, ITEMSTOR, MDDB, PROGRAM,and VIEW.

missing valuein SAS, a term that describes the contents of a variable that contains no data for aparticular row or observation. By default, SAS prints or displays a missing numericvalue as a single period, and it prints or displays a missing character value as ablank space.

observationa row in a SAS data set. All of the data values in an observation are associated witha single entity such as a customer or a state. Each observation contains one datavalue for each variable. In a database product table, an observation is analogous to arow. Unlike rows in a database product table or file, observations in a SAS data filehave an inherent order.

PROC SQL viewa SAS data set (of type VIEW) that is created by the SQL procedure. A PROC SQLview contains no data. Instead, it stores information that enables it to read datavalues from other files, which can include SAS data files, SAS/ACCESS views, DATAstep views, or other PROC SQL views. A PROC SQL view’s output can be either asubset or a superset of one or more files.

querya set of instructions that requests particular information from one or more datasources.

recorda logical unit of information that consists of fields of related data. A collection ofrecords is stored in a file. A record is analogous to a SAS observation.

Page 280: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

272 Glossary

referential integritya set of rules that a DBMS uses to ensure that whenever a data value in one table ischanged, the appropriate change is also made to any related values in other tables orin the same table. Referential integrity is also used to ensure that related data is notdeleted or changed accidentally.

relational database management systema database management system that organizes and accesses data according torelationships between data items. The main characteristic of a relational databasemanagement system is the two-dimensional table. Examples of relational databasemanagement systems are DB2, INGRES, ORACLE, and SQL/DS.

rollbackin most databases, the process that restores a database to its state when changeswere last committed, voiding any changes. The SQL ROLLBACK statement initiatesthe rollback process.

rowin relational database management systems, the horizontal component of a table. Arow is analogous to a SAS observation.

SAS data filea type of SAS data set that contains data values as well as descriptor informationthat is associated with the data. The descriptor information includes informationsuch as the data types and lengths of the variables, as well as the name of the enginethat was used to create the data. A PROC SQL table is a SAS data file. SAS datafiles are of member type DATA.

Page 281: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Glossary 273

SAS data seta file whose contents are in one of the native SAS file formats. There are two types ofSAS data sets: SAS data files and SAS data views. SAS data files contain datavalues in addition to descriptor information that is associated with the data. SASdata views contain only the descriptor information plus other information that isrequired for retrieving data values from other SAS data sets or from files whosecontents are in other software vendors’ file formats.

SAS data viewa type of SAS data set that retrieves data values from other files. A SAS data viewcontains only descriptor information such as the data types and lengths of thevariables (columns), plus other information that is required for retrieving data valuesfrom other SAS data sets or from files that are stored in other software vendors’ fileformats. SAS data views are of member type VIEW.

SAS librarya collection of one or more SAS files that are recognized by SAS and which arereferenced and stored as a unit. Each file is a member of the library.

SAS/ACCESS viewsSee view descriptor and SAS data view.

Structured Query Language (SQL)a standardized, high-level query language that is used in relational databasemanagement systems to create and manipulate database management systemobjects. SAS implements SQL through the SQL procedure.

serverin a network, a computer that is reserved for servicing other computers in thenetwork. Servers can provide several types of services, such as file services andcommunication services. Servers can also enable users to access shared resourcessuch as disks, data, and modems.

Structured Query Language (SQL)the standardized, high-level query language that is used in relational databasemanagement systems to create and manipulate database management systemobjects. SAS implements SQL through the SQL procedure.

tablea two-dimensional representation of data, in which the data values are arranged inrows and columns.

triggera type of user-defined stored procedure that is executed whenever a user issues adata-modification command such as INSERT, DELETE, or UPDATE for a specifiedtable or column. Triggers can be used to implement referential integrity or tomaintain business constraints.

variablea column in a SAS data set or in a SAS data view. The data values for each variabledescribe a single characteristic for all observations. In the ACCESS procedure,variables are created from the PC files’ columns or fields.

viewa definition of a virtual data set. The definition is named and stored for later use. Aview contains no data but describes or defines data that are stored elsewhere. Seealso PROC SQL view, SAS data view, and view descriptor.

view descriptora SAS/ACCESS file that defines part or all of the DBMS data that is described by anaccess descriptor.

Page 282: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

274 Glossary

windowing procedurea SAS procedure that you can use by entering information in one or more windows ordialog boxes. For example, the FSVIEW procedure is a windowing procedure. Someprocedures, such as ACCESS and DBLOAD, can be used either as windowingprocedures or in batch mode.

wildcarda file created by SAS/ACCESS software that defines part or all of the databasemanagement system (DBMS) data or PC file data that is described by an accessdescriptor. The access descriptor describes the data in a single DBMS table, DBMSview, or PC file.

Page 283: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

275

Index

AACCDB file format 44ACCDESC= option

PROC ACCESS statement 200ACCDESC= statement

DBLOAD procedure 221access descriptors 197

creating 202passwords for 197performance and 198resetting column settings 211updating 215WKn files with 241

ACCESS enginecommitting updates 92

ACCESS= LIBNAME option 85, 156access methods 3ACCESS procedure 195, 198

component for Excel 33importing and exporting Excel files 42statements 196syntax 198

ACCESS procedure, DBF (Windows) 248data conversions 249QUIT statement 248syntax 248

ACCESS procedure, DIF 252data conversions 255datetime conversions 255DIFLABEL statement 253QUIT statement 253SKIPROWS statement 254syntax 253

ACCESS procedure, WKn 241data conversions 243GETNAMES statement 242QUIT statement 242RANGE statement 242SCANTYPE statement 242SKIPROWS statement 243syntax 241WORKSHEET statement 243

ACCESS procedure, XLS 230data conversions 232syntax 230

Ace queries 122ASSIGN statement

ACCESS procedure 200

AUTOCOMMIT= argumentCONNECT statement 114, 184

AUTOCOMMIT= data set option 92AUTOCOMMIT= LIBNAME option 85, 156

Bbuffers

reading rows into 108, 177

Ccells 31character data 32, 54

very long character data type 100, 169column names

saved as label names 102variable labels as 99, 168

columnsdate format of 108, 177disallowed characters in 97, 167NULL values 101, 170renaming 97, 167

comma-separated values filesSee CSV files

commandsJet commands 124timing out 93, 163

COMMAND_TIMEOUT= argumentCONNECT statement 114, 184

COMMAND_TIMEOUT= data set option 93, 163COMMAND_TIMEOUT= LIBNAME option 85, 157commit statements

row processing 94, 164configuration

PC Files Server 143CONNECT statement

arguments 114, 184database connection arguments 113Pass-Through Facility, UNIX 181Pass-Through Facility, Windows 113

CONNECTION= argumentCONNECT statement 114, 184

CONNECTION= LIBNAME option 85, 157connection options

Access files 132Excel workbook files 128LIBNAME statement, UNIX 151

Page 284: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

276 Index

CONNECTION TO componentPass-Through Facility, UNIX 189Pass-Through Facility, Windows 120

CONNECTION_GROUP= argumentCONNECT statement 115, 184

CONNECTION_GROUP= LIBNAME option 86, 157CONNECT_STRING= LIBNAME option 151CONNECT_STRING= option

CONNECT statement 182CREATE statement

ACCESS procedure 201CREATE TABLE statement

data source-specific syntax 95, 166CSV files 27

exporting data sets to 30importing into SAS 30importing subsets into SAS 30

cursor type 93, 163CURSOR_TYPE= argument

CONNECT statement 115, 184CURSOR_TYPE= data set option 93, 163CURSOR_TYPE= LIBNAME option 86, 157

Ddata access methods 3DATA= argument

PROC DBLOAD statement 221PROC EXPORT statement 20

data conversionsACCESS procedure, DBF 249ACCESS procedure, DIF 255ACCESS procedure, WKn 243ACCESS procedure, XLS 232DBLOAD procedure, DBF 252DBLOAD procedure, WKn 246DBLOAD procedure, XLS 238

DATA= optionDBF procedure 262DIF procedure 264

data set optionsPC files on Linux and UNIX 162PC files on Windows 92

data setsconverting dBASE files to 261converting dBASE II files to 263converting to dBASE 5 files 263converting to DIF files 264DBF files and 249, 252DIF files and 255exporting to CSV files 30exporting to Excel files 41exporting to Excel workbook files 42, 43importing ranges to 41transferring with DIF files 265WKn files and 243, 246

data source tablesdata type for 104, 172

data sources, supported 7data types

Ace provider 121conversion for Access files 133conversion for Excel workbook files 130DBF 58DIF 258DTA 68

Excel 32for data source tables 104, 172Jet provider 121JMP 63Microsoft Access database 45overriding 103, 172SAV 66WKn 54

database connection argumentsCONNECT statement 113

database fields 57DATAFILE= argument

PROC IMPORT statement 14DATAROW= statement

IMPORT and EXPORT procedures 28DATATABLE= argument

PROC IMPORT statement 15date and time values 54date format

of data source columns 108, 177date/time values

SAS versus Access 136SAS versus Excel 131

date values 33datetime conversions

ACCESS procedure, DIF 255DBLOAD procedure, DIF 257

datetime values 33DB files, Paradox 66dBASE 5 files

converting data sets to 263dBase DBF files 57

ACCESS procedure with 248converting to SAS variables 262data conversions 249, 252DBF data types 58DBLOAD procedure with 249examples of importing and exporting 61missing values 252setting environment variables 59setting system options 59supported IMPORT/EXPORT procedure statements 60transferring other software files to 263

dBase DBFMEMO files 62dBASE files

converting to data sets 261dBASE II files

converting to data sets 263DBCOMMIT= data set option 94, 164DBCOMMIT= LIBNAME option 86, 158DBCONDITION= data set option 95, 165DBCREATE_TABLE_OPTS= data set option 95, 166DBENCODING= data set option 96DBF data types 58DBF fields

converting SAS variables to 263DBF files

See dBase DBF filesDBF procedure 261DBFORCE= data set option 97, 166DBGEN_NAME= argument

CONNECT statement 115, 185DBGEN_NAME= data set option 97, 167DBGEN_NAME= LIBNAME option 87, 158DBGEN_NAME= option

CONNECT statement 115

Page 285: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Index 277

DBKEY= data set option 98, 168format of WHERE clause 101, 171

DBKEY= processingmissing values and 107, 176

DBLABEL= data set option 99, 168DBLOAD procedure 219, 220

component for Excel 33importing and exporting Excel files 42naming conventions 220syntax 220

DBLOAD procedure, DBF (Windows) 249data conversions 252environment variables 252QUIT statement 250syntax 249VERSION statement 250

DBLOAD procedure, DIF 255datetime conversions 257DIFLABEL statement 256environment variables 258FORMAT statement 256QUIT statement 256syntax 256

DBLOAD procedure, WKn 244data conversions 246FORMAT statement 245PUTNAMES statement 245QUIT statement 245syntax 245

DBLOAD procedure, XLS 236data conversions 238syntax 236

DBMAX_TEXT= argumentCONNECT statement 116

DBMAX_TEXT= data set option 100, 169DBMAX_TEXT= LIBNAME option 87, 158DBMAX_TEXT= option

CONNECT statement 185DBMEMO files 62DBMS= argument

PROC DBLOAD statement 221DBMS engines

trace information from 75DBMS= option

PROC ACCESS statement 200PROC EXPORT statement 21PROC IMPORT statement 15

DBMS specificationsEXPORT procedure 21IMPORT procedure 16

DBn optionsDBF procedure 261

DBNULL= data set option 101, 170DBNULLKEYS= data set option 101, 171DBNULLKEYS= LIBNAME option 87, 158DBPASSWORD= LIBNAME option 151DBPASSWORD= option

CONNECT statement 183DBSASLABEL= data set option 102DBSASLABEL= LIBNAME option 88, 159DBSASTYPE= data set option 103, 172DBSYSFILE= LIBNAME option 151DBSYSFILE= option

CONNECT statement 183DBTYPE= data set option 104, 172

DEFER= argumentCONNECT statement 116

DEFER= LIBNAME option 88, 159DEFER= option

CONNECT statement 185DELETE statement

DBLOAD procedure 222delimited files 26

IMPORT and EXPORT procedure statements for 28text files 26

delimiter-separated values (DSV) files 26DELIMITER= statement

IMPORT and EXPORT procedures 28delimiters 26descriptor files 197

examples 203passwords for 197performance and 198

desktop applicationsrunning PC Files Server as 141

DIF file data types 258DIF files

converting to data sets 264missing values and 266transferring data sets with 265

DIF (Lotus) filesACCESS procedure with 252data conversions 255DBLOAD procedure with 255

DIF= optionDIF procedure 264

DIF procedure 264DIF variables

converting to SAS variables 265DIFLABEL statement

ACCESS procedure 253DBLOAD procedure 256

DIRECT_SQL= LIBNAME option 88, 159DISCONNECT statement

Pass-Through Facility, UNIX 187Pass-Through Facility, Windows 117

DLM files 26DNS= LIBNAME option 151DROP statement

ACCESS procedure 205DSN= option

CONNECT statement 182DSV files 26DTA data types 68DTA files 68

EEFI (External File Interface) 11encoding

character set for Access databases 96character set for Excel workbook files 96

encryptionPC Files Server 144

environment variablesdBase DBF files 59Lotus WKn files 247XLS files 240

ERRLIMIT= data set option 104, 173ERRLIMIT= statement

DBLOAD procedure 222

Page 286: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

278 Index

error limit, before rollback 104, 173Excel 2007 31, 41Excel files 31Excel workbooks 31EXECUTE statement

Pass-Through Facility, UNIX 187Pass-Through Facility, Windows 118

EXPORT procedure 19Access table specification compatibility 23DBMS specifications 21Excel spreadsheet specification compatibility 23features of 7statements for delimited files 28supported data sources and platforms 7syntax 20

export utilities 33Export Wizard 11

features of 7supported data sources and platforms 7

exportingAccess files 46data sets to Excel files 41data sets to Excel workbook files 42, 43DB files 66DBF files 60, 61DTA files 70Excel files with ACCESS and DBLOAD procedures 42Excel files with LIBNAME statement 34JMP files 64, 65WKn files 55, 56XLS files 43

External File Interface (EFI) 11extracting data 197

view descriptors for 198

Ffile formats

ACCDB 44Access database files 44CSV 27DBF 57DBFMEMO 62DLM 26DSV 26DTA 68JMP 62MDB 44, 46Paradox DB 66SAV 66TAB 27WKn 53XLS 31, 34XLSB 31, 41XLSM 31XLSX 31

FILELOCK= LIBNAME option 89FORMAT statement

ACCESS procedure 205DBLOAD procedure 245, 256

functions 80, 150

GGETNAMES statement

ACCESS procedure 242

IMPORT and EXPORT procedures 29GUESSINGROWS= statement

IMPORT and EXPORT procedures 29

IIMPORT procedure 13

DBMS specifications 16Excel spreadsheet specification compatibility 17Excel spreadsheet specifications 17features of 7statements for delimited files 28supported data sources and platforms 7

import utilities 33Import Wizard 11

supported data sources and platforms 7importing

Access files 46data using a range name 44data using absolute range address 44DB files 66DBF files 60, 61DTA files 70Excel files with ACCESS and DBLOAD procedures 42Excel files with LIBNAME statement 34JMP files 64, 65ranges to data sets 41WKn files 55, 56XLS files 43

INIT= argumentCONNECT statement 113

INIT= LIBNAME option 82insert processing

missing values and 107, 176INSERTBUFF= data set option 106, 175INSERTBUFF= LIBNAME option 89, 160INSERT_SQL= data set option 105, 174INSERT_SQL= LIBNAME option 89installing PC Files Server 140

JJet commands 124Jet queries 122JMP data types 63JMP files 62

examples of importing and exporting 64, 65importing and exporting data in 64missing values 62

joinsperformance improvement 98, 168

LLABEL option

PROC EXPORT statement 24LABEL statement

DBLOAD procedure 223LABELS option

DIF procedure 264LIBNAME connection options

Access files 132Excel workbook files 128

LIBNAME engines 73macro variables 74software requirements 74

Page 287: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Index 279

trace system options 75LIBNAME options

PC files on Linux and UNIX 156LIBNAME statement, PC files 33, 79, 81

assigning librefs 80, 84connection options 82connection options on UNIX 151for Access files 132for Excel workbook files 127functions with PC files data 80importing and exporting Excel files 34on 64-bit Microsoft Windows 149on Linux 149on UNIX 149sorting data 80syntax 81syntax, on Linux 150syntax, on UNIX 150

librariesdisassociating librefs from 154writing attributes to log 84, 154

librefsassigning 80, 84assigning to Access databases 154assigning to Excel workbooks 155assigning to Oracle databases 156assigning to SQL Server databases 156disassociating 84, 154

LIMIT= statementDBLOAD procedure 223

Linuxdata set options 162LIBNAME options 156LIBNAME statement 150

LIST statementACCESS procedure 206DBLOAD procedure 224

LOAD statementDBLOAD procedure 225

logwriting library attributes to 84, 154

Lotus DIF filesACCESS procedure with 252data conversions 255DBLOAD procedure with 255

Lotus WKn data types 54Lotus WKn files 53

ACCESS procedure with 241data conversions 243, 246DBLOAD procedure 244environment variables 247examples of importing and exporting 56import and export components and statements 55

Mmacro variables 74MDB file format 44

IMPORT and EXPORT procedure statements 46Microsoft Access

assigning librefs to databases 154encoding character set for database 96LIBNAME statement, PC files on UNIX 153table specification compatibility 23

Microsoft Access database data types 45

Microsoft Access database files 44IMPORT and EXPORT procedure statements for 46with IMPORT and EXPORT procedures 46

Microsoft Access filesdata types conversion for 133file-specific reference 132LIBNAME connection options for 132LIBNAME statements for 132

Microsoft Ace provider data types 121Microsoft Excel

assigning librefs to workbooks 155data types 32DBMS spreadsheet specifications 17import and export components 33LIBNAME statement, PC files on UNIX 153spreadsheet specification compatibility 17, 23workbooks 31

Microsoft Excel 2007 31, 41Microsoft Excel files 31

exporting data sets to 41importing/exporting with ACCESS and DBLOAD proce-

dures 42importing/exporting with LIBNAME statement 34importing ranges to data sets 41

Microsoft Excel workbook files 31data types conversion for 130encoding character set for 96exporting data sets to 42, 43file-specific reference 127LIBNAME connection options for 128LIBNAME statements for 127

Microsoft Jet provider data types 121Microsoft Windows

Pass-Through Facility on 111missing values

DBF files 252DBKEY= processing and 107, 176DIF file conversions 266insert processing and 107, 176JMP files 62update processing and 107, 176

MIXED statementACCESS procedure 207

MSENGINE= argumentCONNECT statement 116

MSENGINE= LIBNAME option 89, 152MSENGINE= option

CONNECT statement 183

Nnaming conventions

DBLOAD procedure 220NULL values

in columns 101, 170NULLCHAR= data set option 107, 176NULLCHARVAL= data set option 107, 176numeric data 32, 54

OOracle

assigning librefs to databases 156ordering PC files data 95, 165OUT= argument

PROC IMPORT statement 15

Page 288: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

280 Index

OUT= optionDBF procedure 262DIF procedure 264PROC ACCESS statement 200

OUTFILE= argumentPROC EXPORT statement 20

OUTTABLE= argumentPROC EXPORT statement 21

overriding data types 103, 172

PParadox DB files 66

examples of importing and exporting 66Pass-Through Facility, UNIX 179

return codes 181special queries 190syntax 180

Pass-Through Facility, Windows 111CONNECT statement 113CONNECTION TO component 120DISCONNECT statement 117EXECUTE statement 118return codes 112syntax 112

PASSWORD= LIBNAME option 152PASSWORD= option

CONNECT statement 183passwords

access descriptors 197descriptor files 197view descriptors 197

PATH= argumentCONNECT statement 113

PATH= LIBNAME option 82, 152PATH= option

CONNECT statement 182PATH= statement

ACCESS procedure 208DBLOAD procedure 225

PC filesACCESS procedure 195assigning librefs 80, 84data access methods 3data set options 92DBLOAD procedure 219descriptor files 197functions with PC files data 80, 150LIBNAME statement for 79Pass-Through Facility on UNIX 179sorting data 80, 95, 150, 165special queries 190subsetting data 95, 165

PC Files Server 139configuring 143constraints 147data encryption 144installation 140maximum connections 144modes 140port number 143running as desktop application 141running as Windows Service 140service name 143shared information 147

PCFFSCL.SAS file 233

performancedescriptors and 198joins 98, 168

platforms, supported 7PORT= LIBNAME option 152port number

PC Files Server 143PORT= option

CONNECT statement 182PREFIX= option

DIF procedure 265printing

SASTRACE information 78PROC ACCESS statement 199PROC DBLOAD statement 221PROC EXPORT statement 20PROC IMPORT statement 14PROMPT= argument

CONNECT statement 113PROMPT= LIBNAME option 83PUTNAMES statement

DLOAD procedure 245IMPORT and EXPORT procedures 29

Qqueries

Jet and Ace 122special PC files queries 190

QUIT statementACCESS procedure 209, 242, 248, 253DBLOAD procedure 226, 245, 250, 256

Rrange names

importing data with 44RANGE statement

ACCESS procedure 242ranges 31

importing to data sets 41READBUFF= argument

CONNECT statement 116READBUFF= data set option 108, 177READBUFF= LIBNAME option 90, 160READBUFF= option

CONNECT statement 185RENAME statement

ACCESS procedure 209DBLOAD procedure 226

REPLACE optionPROC EXPORT statement 24PROC IMPORT statement 17

RESET statementACCESS procedure 210DBLOAD procedure 227

return codesPass-Through Facility, UNIX 181Pass-Through Facility, Windows 112

rollback, error limit for 104, 173row processing

commit statement for 94, 164rows

insertion method 105, 174number for single insert 106, 175number to read into buffer 108, 177

Page 289: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Index 281

Ssample data 4SASDATEFMT= data set option 108, 177SASTRACE= system option 75

printing trace information 78SASTRACELOC= system option 78SAV data types 66SAV files 66SCAN_TEXTSIZE= LIBNAME option 90, 160SCAN_TIMETYPE= LIBNAME option 90, 161SCANTYPE statement

ACCESS procedure 242SELECT statement

ACCESS procedure 212SERVER= LIBNAME option 152SERVER= option

CONNECT statement 182service name

PC Files Server 143shared information

PC Files Server 147SKIP= option

DIF procedure 265SKIPROWS statement

ACCESS procedure 243, 254software requirements, for LIBNAME engine 74sorting PC files data 80, 95, 150, 165space-separated data values

importing into SAS 30SPOOL= LIBNAME option 91, 161SPSS SAV data types 66SPSS SAV files 66SQL Server

assigning librefs to databases 156SQLXMSG macro variable 112, 181SQLXRC macro variable 112, 181SS_MIXED environment variable 247SS_NAMES environment variable 247SS_SCAN environment variable 247Stata DTA data types 68Stata DTA files 68

examples of importing and exporting 70STRINGDATES= argument

CONNECT statement 116STRINGDATES= LIBNAME option 91, 161STRINGDATES= option

CONNECT statement 186SUBSET statement

ACCESS procedure 213subsetting

importing CSV file subsets 30PC files data 95, 165

supported data sources 7supported platforms 7system options

dBase DBF files 59for tracing 75

TTAB files 27time values 33timeout for commands 93, 163trace information

from DBMS engine 75

trace system options 75truncation, forcing 97, 166TYPE statement

ACCESS procedure 213

UUDL= argument

CONNECT statement 114UDL= LIBNAME option 83UNICODE= LIBNAME option 91UNIQUE statement

ACCESS procedure 214UNIX

accessing PC data from 154data set options 162LIBNAME options 156LIBNAME statement 150Pass-Through Facility 179

update processingmissing values and 107, 176

UPDATE statementACCESS procedure 215

updating datamissing values and 252

USE_DATATYPE= LIBNAME option 91, 162USE_DATETYPE= argument

CONNECT statement 116USER= LIBNAME option 153USER= option

CONNECT statement 183utilities

import and export 33

Vvariables

converting DBF fields to SAS variables 262converting DIF variables to SAS variables 265converting SAS variables to DBF fields 263DBF files and 249, 252DIF files and 255WKn files and 243, 246

VERSION= LIBNAME option 153, 183VERSION statement

DBLOAD procedure 250very long character data type 100, 169view descriptors 197

creating 202extracting data with 198passwords for 197performance and 198resetting column settings 211updating 216

VIEWDESC= optionPROC ACCESS statement 200

WWHERE clause

format of, with DBKEY= data set option 101, 171WHERE statement

DBLOAD procedure 228Windows Service

running PC Files Server as 140WKn data types 54

Page 290: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

282 Index

WKn filesSee also Lotus WKn filesACCESS procedure 241data conversions 243, 246DBLOAD procedure 244environment variables 247

WORKSHEET statementACCESS procedure 243

worksheets 31

XXLS file formats 34

importing/exporting 43

XLS files 31ACCESS procedure 230data conversions 232, 238DBLOAD procedure 236environment variables 240

XLSB files 31, 41XLSM files 31XLSX files 31

Page 291: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

Your Turn

We welcome your feedback.� If you have comments about this book, please send them to [email protected].

Include the full title and page numbers (if applicable).� If you have comments about the software, please send them to [email protected].

Page 292: SAS/ACCESS 9.2 Interface to PC Files Referencemorgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/...Contents What’s New vii Overview vii Enhanced Support for the Wizards

66