| File Format-Specific Reference for the IMPORT and EXPORT Procedures |
The IMPORT and EXPORT components use the ACCESS and DBLOAD procedures behind 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 only on Microsoft Windows.
Note: Because the ACCESS and DBLOAD procedures are compatible only
with SAS 6 procedures, they ignore SAS system options such as the VALIDVARNAME
= option. The ACCESS procedure and the DBLOAD procedure have other SAS 6 limitations
such as a maximum of 8-byte SAS variable names and a maximum of 200-character
value. ![[cautionend]](../../../../common/62850/HTML/default/images/cautend.gif)
The following table lists the statements that are available to import data from or export data to an Excel file using the ACCESS and DBLOAD procedures. For examples of these statements, see ACCESS and DBLOAD Procedures Options.
| Data Source | Syntax | Valid Value | Default Value | PROC IMPORT | PROC EXPORT |
| EXCEL5 | GETNAMES= | Yes|No | Yes | Yes | No |
| RANGE= | Range Name or Absolute Range Value, such as 'A1..C4' |
|
Yes | No | |
| SHEET= | Sheet name |
|
Yes | No | |
| EXCEL4 | GETNAMES= | Yes| No | Yes | Yes | No |
| RANGE= | Range Name or Absolute Range Value, such as 'A1..C4' |
|
Yes | No |
| ACCESS and DBLOAD Procedures Options |
specifies whether the IMPORT procedure is to generate SAS variable names from the 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 SAS variable name, such as a blank; SAS converts the character to an underscore. For example, the column heading.
| YES |
specifies that the IMPORT procedure generate SAS variable names from the data values in the first row of the imported Excel file. |
| NO |
specifies that the IMPORT procedure generate SAS variable names as F1, F2, F3, and so on. |
This code exports the SDF.INVOICE and SDF.ORDERS SAS data sets to Excel workbook 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; PROC EXPORT DATA=SDF.ORDERS FILE="&tmpdir.text.xls" DBMS=XLS REPLACE; SHEET="Orders"; RUN;
This code imports SAS data from an .xls file using a range name.
PROC IMPORT OUT=WORK.INVOICE FILE="&demodir.demo.xls" DBMS=XLS REPLACE; RANGE="INVOICE"; GETNAMES=YES; RUN;
Import SAS data from an .xls file using an absolute range address.
PROC IMPORT OUT=WORK.INVOICE FILE="&demodir.demo.xls" DBMS=XLS REPLACE; RANGE="Invoice$B4:D10"; GETNAMES=NO; RUN;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.