| Using the IMPORT Procedure |
| Support: | The IMPORT procedure is available for these
operating environments:
|
|
PROC IMPORT
DATAFILE="filename" OUT=<libref.>SAS-data-set <DBMS=data-source-identifier><REPLACE> ; |
| Required Arguments |
specifies the complete path and filename or fileref for the input 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. You can omit the quotation marks if the file-name does not include certain characters such as these:
backslash
lowercase characters
spaces
| Alias: | FILE |
| See also: | The FILENAME statement in SAS Language Reference: Dictionary |
| 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: | For client server applications. When running SAS/ACCESS on UNIX, to access data stored on a PC server, you must specify the full path and filename of the import file. The use of a fileref is not supported. |
| Restriction: | The IMPORT procedure can import data if the data type is supported by SAS. 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 import it correctly. In many cases, the procedure attempts to convert the data to the best of its ability. However, at times this is not possible. |
| Interaction: |
For some input data sources such
as a Microsoft Excel spreadsheet, the first eight rows of data are scanned.
The most prevalent data type (numeric or character) is used for a column.
This is the default. If most of the data in the first eight rows is missing:
|
| Default: | character |
| Note: | For information about how SAS converts data types, see the specific information for the data source file format that you are importing. |
| Note: | To import DBF files created with Microsoft Visual FoxPro, you must export to an appropriate dBASE format using Visual Fox PRO. Import the dBASE file to SAS. |
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 quotation marks. The DBMS table name might be case sensitive.
| Alias: | TABLE |
| Requirement: | When importing Microsoft Access tables, SAS/ACCESS converts the table name to a SAS member name. SAS does not support member names longer than 32 bytes. |
| Requirement: | When you import a DBMS table, you must specify the DBMS= option. |
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 SASUSER library if assigned, or the WORK library if SASUSER not assigned.
| Featured in: | All examples. |
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 options. To import only data that meets a specified condition, you can use the WHERE data set option.
For information about all SAS data set options, see the data set options section in SAS Language Reference: Dictionary.
| Statement Options |
specifies the type of data to import. To import a DBMS table, you must specify DBMS = using a valid database identifier; DBMS=ACCESS specifies to import a Microsoft Access 2000, 2002, or 2003 table. Only specify the DBMS= option to import files, if DATAFILE contains an extension that the IMPORT procedure cannot recognize.
For example, the IMPORT procedure recognizes the filename ACCOUNTS.WK1 as a Lotus 1-2-3 Release 2 spreadsheet and the filename MYDATA.CSV as a delimited external file that contains comma-separated data values. Therefore, a DBMS= specification is not necessary.
The following values are valid for the DBMS= option. For detailed information about supported data sources and environments, see Supported Data Sources and Environments. For information about accessing PC Files Data, see Methods for Accessing PC Files Data.
| Restriction: |
The availability of a data source
depends on:
|
When you specify a value for DBMS= consider the following:
When you specify DBMS=XLS for an Excel file, you can read and write Excel spreadsheets under UNIX directly, without having to access the PC Files Server.
Microsoft Access versions 2000, 2002, and 2003 share the same internal file formats. The SAS LIBNAME engine recognizes ACCESS 2000, ACCESS 2002, ACCESS 2003, and ACCESS 2007 as aliases for the identifier ACCESS. By specifying DBMS=ACCESS, SAS can read any of these versions of files that are saved in Microsoft Access applications.
Microsoft Excel versions 97, 2000, 2002, and 2003 share the same internal file formats. The SAS LIBNAME engine recognizes EXCEL 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007 as aliases for the identifier Excel.
| Identifier | Excel 2007 | Excel 97, 2000, 2002, 2003 | Excel 5.0, 95 | Excel 4.0 |
|---|---|---|---|---|
| XLS | no | yes | yes | no |
| EXCEL | yes | yes | yes | yes |
| EXCEL5 | no | no | yes | yes |
| EXCEL4 | no | no | yes | yes |
This table summarizes the access technology used based on the DBMS specifications.
| Note: | Although Excel 4.0 and Excel 5.0 spreadsheets are often interchangeable, it is recommended that you specify the exact version. |
overwrites an existing SAS data set. If you do not specify REPLACE, the IMPORT procedure does not overwrite an existing data set.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.