File Format-Specific Reference for the IMPORT and EXPORT Procedures |
Before 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 file, you can specify DBMS=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.
See Example 1: Import a SAS Data Set from an Access 2007 Database Table and Example 2: Export a SAS Data Set to Create an Access97 Database File.
Data Source | Syntax | Valid Value | Default Value | PROC IMPORT | PROC EXPORT? |
ACCESS
ACCESS97 ACCESS2000 ACCESS2002 ACCESS2003 ACCESS2007 |
DATABASE | Complete path and filename for the Microsoft Access database file. |
|
Yes | Yes |
DBDSOPTS | Any valid data set options 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 | |
DBSYSFILE | Complete path and filename for the Workgroup Administration file. |
|
Yes | Yes |
On Linux, UNIX, and Windows 64-Bit operating platforms, you can use the client/server model to access data in .mdb files and .accdb files. For more information, see PC Files Server Administration.
For an existing .mdb you can specify DBMS=ACCESSCS when using the client/server model and SAS identifies the version of Access for you. You can specify VERSION='97' when using the client/server model only when you want to export and create a new .mdb file with Access version 97 formats.
Note: If the client/server model is used, the SAS client cannot access an Access database 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 your Access database file from a SAS client.
The following table lists the statements to import or export data to or from an Access database file using the client/server model. The statements are valid on Linux, UNIX, and Windows 64-bit operating platforms.
Data Source | Syntax | Valid Value | Default Value | PROC IMPORT | PROC EXPORT |
ACCESSCS | DATABASE | Complete path and filename for the Microsoft Access database file. |
|
Yes | Yes |
DBDSOPTS | Any valid data set options 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 | |
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 | |
DBWSYSFILE | Complete path and filename for the Workgroup Administration file. |
|
Yes | Yes |
specifies the complete path and filename of the Access database file that contains the specified DBMS table. If the database name does not contain lowercase characters, special characters, or national characters ($, #, or @), you can omit the quotation marks.
Note: | SAS does not generate a default value, but you can configure one in the DBMS client software |
data set options that are valid for the Access database LIBNAME engine
Enables you to take advantage of useful data set options for the LIBNAME engine such as READBUFF=, INSERTBUFF=, DBTYPE=, DROP=, FIRSTOBS=, and OBS=. This option is for advanced users who are familiar with the PC files LIBNAME engine.
Note: | For users who use the client/server model to access data in an Access database, the default value for READBUFF= is 1. To improve performance for reading data, set READBUFF= to 25 or higher. |
Note: | For users who use the client/server model to access data in an Access database, the default value for INSERTBUFF= is 1. To improve performance for writing data, set INSERTBUFF= to 25 or higher. |
See: | For a list of supported data set options, refer to Data Set Options Data Set Options for PC Files on Linux and UNIX, and 64-Bit Windows |
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 quotations marks, you must use double quotation marks around it in your statement. |
Example: |
DBDSOPTS="DBTYPE=(BilledTo='CHAR(8)')"; |
enables you to access a file if database-level security is set in the .mdb file. A database password is case sensitive. You can define a database password instead of user-level security.
Alias: | DBPWD|DBPW |
specifies the data source for column names.
COMPAT |
specifies that the data source column headings are saved as the corresponding SAS label names.
| ||
NONE |
specifies that the data source column headings are not saved as SAS label names. The SAS label names are then left as blanks.
|
Restriction: | Due to a Microsoft Jet engine limitation, no more than 64 characters of column names are written to SAS variable labels. |
Restriction: | 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. |
Specifies the maximum variable length in SAS that is allowed while importing data from memo columns of an Access database table. Any memo data in an Access database tables whose length exceeds 32767 is truncated when it is imported into SAS.
Alias: | DBMAX_TEXT |
Note: | DBMAX_TEXT |
Restriction: | 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. |
specifies the number of the port that is listening on the PC Files Server. The valid value is between 1 and 65535. This port or service name displays on the PC Files Server display when the application is started in server mode.
Default: | 8621 |
Alias: | PORT_NUMBER |
Restriction: | 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 |
specifies whether to scan the memo data to determine the column length for each memo-type source column.
scans the length of memo data for a data source column. Uses the length of the longest memo text of data that it finds, as the SAS variable width.
Restriction: | 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. |
does not scan the length of memo data for a data source column. The column length returned from the Microsoft Ace engine or the Microsoft Jet engine is used as the SAS variable length.
Restriction: | SCANMEMO= does not apply to text type columns. |
Restriction: | This option applies only to memo data type columns. |
specifies whether to scan the date/time data while importing data from a date/time column from an Access database.
scans the date/time column and assigns the TIME. format for a date/time column only if time values are found in the column.
Note: | The DATE9. format is assigned for a date/time column if USEDATE=YES. |
specifies not to scan the date/time column.
Note: | The DATETIME. format is assigned for a date/time column if USEDATE=NO. |
specifies the name of the PC Files Server. You must bring up the listener on the PC Files Server before you can establish a connection to it. You can also configure these items:
the service name
the port number
the maximum number of concurrent connections
encrypt the data
Alias: | SERVER_NAME |
Note: | This statement is a required. |
Restriction: | Available only for the client/server model. |
specifies the password for the User ID given. If the account has no password, omit this option. Always enclose the value in quotes, this preserves the case of the password.
specifies 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 misinterpreted by the SAS parser.
specifies the service name that is defined on your service file for your client and server machines. This port number or service name is displayed on the PC Files Server control panel screen when it is started on the PC in server mode.
Alias: | SERVICE_NAME |
Note: | 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. |
enables PC Files Server to allow Integrated Windows Authentication. This is a mechanism for Windows client and server to exchange credentials.
specifies whether to assign a DATE. or a DATETIME. format while importing a date/time column from a Microsoft ACCESS workbook.
assigns the DATE. format for the corresponding date/time column in the Microsoft ACCESS table.
assigns the DATETIME. format for the corresponding date/time column in the Microsoft ACCESS table.
See also: | The SCANTIME= statement option in order to assign the appropriate TIME format. |
For processing of date and time values between SAS and Microsoft Access, see Processing Date and Time Values between SAS and Microsoft Access.
specifies 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.
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 Table |
This code imports a data set named CUSTOMER from the Customers table in a Microsoft Access database: demo.accdb. The Microsoft Access table was saved in version 2007 format.
PROC IMPORT OUT=WORK.CUSTOMER DATATABLE='Customers' DBMS=ACCESS REPLACE; DATABASE="&demodir.demo.accdb"; USEDATE=YES; SCANTIME=NO; DBSASLABEL=NONE; RUN;
Example 2: Export a SAS Data Set to Create an Access97 Database File |
This 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 the EXPORT procedure is submitted. SAS loads and names the table Employees. It then creates 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 Read Buffer |
This code imports a data set named INVOICE from the Invoice table in a Microsoft Access database named demo.mdb. The read buffer is set to 10 rows.
PROC IMPORT OUT=SDF.INVOICE TABLE='Invoice' DBMS=ACCESSCS REPLACE; DATABASE="&pcfdir.demo.mdb"; SERVER="&server"; DBDSOPTS='READBUFF=10'; RUN;
Example 4: Export a SAS Data Set to an Access Database File on a PC Files Server |
This code exports a SAS data set named ORDERS to a new Microsoft Access database file named TEST.MDB, located on the PC Files Server. The write buffer is set to 25 rows.
The code performs these tasks:
LIBNAME SDF "&sasdir"; PROC EXPORT DATA=SDF.ORDERS (DROP=SPECINST) OUTTABLE='Orders' DBMS=ACCESSCS REPLACE LABEL; SERVER="&server"; VERSION='97'; DBDSOPTS='INSERTBUFF=25'; RUN;
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.