Previous Page | Next Page

The IMPORT Procedure

PROC IMPORT Statement


Featured in: Examples: IMPORT Procedure

PROC IMPORT
DATAFILE="filename"
OUT=<libref.>SAS data-set <(SAS data-set-options)>
<DBMS=identifier><REPLACE> ;

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 Language Reference: Dictionary. For more information about PC file formats, see SAS/ACCESS Interface to PC Files: Reference.

Restriction: 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.
Restriction: 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 width that the IMPORT procedure supports is 32767.
Restriction: 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.
Interaction: For delimited files, the first 20 rows are scanned to determine the variable attributes. You can increase the number of rows scanned by using the GUESSINGROWS data source statement. For more information, see Data Source Statements. 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 will be declared as numeric. Otherwise, the type remains character.
Featured in: Importing a Delimited External File, Importing a Specific Delimited File Using a Fileref, Importing a Tab-Delimited File, and Importing a Comma-Delimited File with a CSV Extension
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).

Featured in: Examples: IMPORT Procedure
(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. For information about SAS data set options, see "Data Set Options" in SAS Language Reference: Dictionary SAS Language Reference: Dictionary.

Restriction: You cannot specify data set options when importing delimited, comma-separated, or tab-delimited external files.

Options

DBMS=identifier

specifies the type of data to import. Valid identifiers for delimited files are CSV, DLM, JMP, and CSV. 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.

Featured in: Importing a Delimited External File and Importing a Tab-Delimited File.
REPLACE

overwrites an existing SAS data set. If you do not specify the REPLACE option, the IMPORT procedure does not overwrite an existing data set.

Featured in: Importing a Delimited External File.

Previous Page | Next Page | Top of Page