IMPORT Procedure

PROC IMPORT Statement

Imports an external data file to a SAS data set.

Syntax

Required Arguments

DATAFILE="filename"
specifies the complete path and filename or fileref for the input PC file, spreadsheet, or delimited external file. A fileref is a SAS name that is associated with the physical location of the output file. To assign a fileref, use the FILENAME statement. If you specify a fileref or if the complete path and filename does not include special characters such as the backslash in a path, lowercase characters, or spaces, then you can omit the quotation marks. For more information about the FILENAME statement, see SAS Statements: Reference. For more information about PC file formats, see SAS/ACCESS Interface to PC Files: Reference.
Restrictions:The IMPORT procedure does not support device types or access methods for the FILENAME statement except for DISK. For example, the IMPORT procedure does not support the TEMP device type, which creates a temporary external file.

The IMPORT procedure can import data only if SAS supports the data type. 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 not support, the IMPORT procedure might not be able to import it correctly. In many cases, the procedure attempts to convert the data to the best of its ability. However, conversion is not possible for some types.

Interactions:When you use a fileref to specify a delimited file to import, the logical record length (LRECL) defaults to 256, unless you specify the LRECL in the FILENAME statement. The maximum LRECL that the IMPORT procedure supports is 32767.

For delimited files, the first 20 rows are scanned to determine the variable attributes. You can increase the number of rows scanned using the GUESSINGROWS data source statement. All values are read in as character strings. If a Date and Time format, or numeric informat can be applied to the data value, the type is declared as numeric. Otherwise, the type remains character.

OUT=<libref.>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, the IMPORT procedure creates it. If you specify a one-level name, by default the IMPORT procedure uses either the USER library (if assigned) or the WORK library (if USER is not assigned).
TABLE="tablename"
specifies the 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 quotation marks. Note that the DBMS table name might be case sensitive.
Requirements:You must have a license for SAS/ACCESS Interface to PC Files to import to a DBMS table.

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

Optional Arguments

DBMS=identifier
specifies the type of data to import. You can import JMP files (DBMS=JMP) or delimited files. To import a tab-delimited file, specify TAB as the identifier. To import any other delimited file that does not end in .CSV, specify DLM as the identifier. For a comma-separated file with a .CSV extension, DBMS= is optional. The IMPORT procedure recognizes .CSV as an extension for a comma-separated file.
See:DBMS Identifiers Supported in Base SAS for more information about identifiers for this option.

SAS/ACCESS Interface to PC Files: Reference for a list of additional DBMS values when using SAS/ACCESS Interface to PC Files.

REPLACE
overwrites an existing SAS data set. If you do not specify REPLACE, the IMPORT procedure does not overwrite an existing data set.
SAS data set options
specifies SAS data set options. For example, to assign a password to the resulting SAS data set, you can use the ALTER=, PW=, READ=, or WRITE= data set option. To import only data that meets a specified condition, you can use the WHERE= data set option.
Restriction:You cannot specify data set options when importing delimited, comma-separated, or tab-delimited external files.
See:SAS Data Set Options: Reference.