Chapter Contents

Previous

Next
The IMPORT Procedure

PROC IMPORT Statement


Featured in: All examples

PROC IMPORT
DATAFILE="filename" | TABLE="tablename"
OUT=SAS-data-set
<DBMS=identifier><REPLACE>;


Required Arguments

DATAFILE="filename"
specifies the complete path and filename of the input PC file, spreadsheet, or delimited external file. If the name does not include special characters (such as the backslash in a path), lowercase characters, or spaces, you can omit the quotes.
Featured in: Importing a Delimited External File and Importing an Excel Spreadsheet

TABLE="tablename"
specifies the table name of the input DBMS table. If the name does not include special characters (such as question marks), lowercase characters, or spaces, you can omit the quotes. Note that the DBMS table name may be case-sensitive.
Requirement: When you import a DBMS table, you must specify the DBMS= option.
Featured in: Importing a Microsoft Access Table

OUT=SAS-data-set
identifies the output SAS data set with either a one- or two-level SAS name (library and member name). If the specified SAS data set does not exist, PROC IMPORT creates it. If you specify a one-level name, PROC IMPORT uses the WORK library.
Featured in: All examples


Options

DBMS=identifier
specifies the type of data to import. For example, DBMS=DBF specifies to import a dBASE file. For PC files, spreadsheets, and delimited external files, you do not have to specify DBMS= if the filename specified with DATAFILE= contains a valid extension so that PROC IMPORT can recognize the type of data. For example, PROC IMPORT recognizes the filename ACCOUNTS.WK1 as a Lotus 1 spreadsheet and the filename MYDATA.CSV as a delimited external file that contains comma-separated data values. PROC IMPORT can recognize the difference between Excel Version 4 and Version 5 spreadsheets when you use the extension .XLS, regardless of whether you specify DBMS=EXCEL, DBMS=EXCEL4, or DBMS=EXCEL5. However, you must specify DBMS=EXCEL97 to import Excel 97 spreadsheets. If you do not specify an identifier or if the extension of the filename is not recognized, an error is returned.

To import a DBMS table, you must specify DBMS= using a valid database product. For example, DBMS=ACCESS imports a Microsoft Access table.

The DBMS= specification can include the values listed in the following table:

Available DBMS Specifications
Identifier Input Data Source Extension
ACCESS Microsoft Access database .MDB
DBF dBASE file .DBF
WK1 Lotus 1 spreadsheet .WK1
WK3 Lotus 3 spreadsheet .WK3
WK4 Lotus 4 spreadsheet .WK4
EXCEL Excel Version 4 or 5 spreadsheet .XLS
EXCEL4 Excel Version 4 spreadsheet .XLS
EXCEL5 Excel Version 5 spreadsheet .XLS
EXCEL97 Excel 97 spreadsheet .XLS
DLM delimited file (default delimiter is a blank) .*
CSV delimited file (comma-separated values) .CSV
TAB delimited file (tab-delimited values) .TXT

Restriction: The data sources available to you depend on the SAS/ACCESS products that you have licensed. If you do not have any SAS/ACCESS products licensed, then the only types of data source files available to you are .CSV, .TXT, and delimited files.
Restriction: The OS/2 operating environment does not support Excel 5 and Excel 97 spreadsheets.
Featured in: Importing a Delimited External File and Importing a Microsoft Access Table

REPLACE
overwrites an existing SAS data set. If you do not specify REPLACE, PROC IMPORT does not overwrite an existing data set.
Featured in: Importing a Delimited External File


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.