Chapter Contents

Previous

Next
The IMPORT Procedure

Data Source Statements


Featured in: All examples

PROC IMPORT provides a variety of statements that are specific to the input data source.


Statements for PC Files, Spreadsheets, or Delimited External Files
Statements for PC Files, Spreadsheets, and Delimited External Files describes which statements are available to import PC files, spreadsheets, and delimited external files, and it denotes which statements are valid for a specific data source. For example, Excel spreadsheets have optional statements to indicate whether column names are in the first row of data or which sheet and range of data to import, while a dBASE file (.DBF) does not. For more information about PC file formats, see SAS/ACCESS Software for PC File Formats: Reference.

Statements for PC Files, Spreadsheets, and Delimited External Files
Input Type Statements
GETNAMES= RANGE= SHEET= DELIMITER= GETDELETED= DATAROW=
DBF



X
WK1 X X X


WK3 X X X


WK4 X X X


EXCEL X X X


EXCEL4 X X X


EXCEL5 X X X


EXCEL97 X X X


DLM X

X
X
CSV X



X
TAB X



X

DATAROW=n
starts reading data from row number n in the external file.
Default:
1 when GETNAMES=NO
2 when GETNAMES=YES (default for GETNAMES=)
Interaction: When GETNAMES=YES, DATAROW must be [ge] 2. When GETNAMES=NO, DATAROW must be [ge] 1.

DELIMITER='char'|'nn'x
for a delimited external file, specifies the delimiter that separates columns of data in the input file. You can specify the delimiter as a single character or as a hexidecimal value. For example, if columns of data are separated by an ampersand, specify DELIMITER='&'. If you do not specify DELIMITER=, PROC IMPORT assumes that the delimiter is the blank. You may replace the equals sign with a blank.
Featured in: Importing a Delimited External File

GETDELETED=YES|NO
for a DBF file, indicates whether to write records to the SAS data set that are marked for deletion but have not been purged. You may replace the equals sign with a blank.
Default: NO

GETNAMES=YES|NO
for spreadsheets and delimited external files, determines whether to generate SAS variable names from the column names in the input file's first row of data. If you specify GETNAMES=NO or if the column names are not valid SAS names, PROC IMPORT uses the variable names VAR0, VAR1, VAR2, and so on. You may replace the equals sign with a blank.
Default: YES
Featured in: Importing a Delimited External File and Importing an Excel Spreadsheet

RANGE=range-name|absolute-range
subsets a spreadsheet by identifying the rectangular set of cells to import from the specified spreadsheet. The syntax for range-name and absolute-range is native to the file being read. The range-name is the name that is assigned to a range address within a spreadsheet. The absolute-range identifies the top left cell that begins the range and bottom right cell that ends the range. The beginning and ending cells are separated by two periods. For example, C9..F12 specifies a cell range that begins at cell C9, ends at cell F12, and includes all the cells in between. If you do not specify RANGE=, PROC IMPORT reads the entire spreadsheet. You may replace the equals sign with a blank.
Restriction: You cannot use absolute-range with Excel 97 spreadsheets.

SHEET=spreadsheet-name
for spreadsheets, identifies a particular spreadsheet to read from a group of spreadsheets, for example, SHEET=PRICES. Use this statement with spreadsheet files that support multiple spreadsheets within a single file, such as EXCEL5, EXCEL97, WK3, and WK4. The naming convention for the spreadsheet name is native to the file being read. If you do not specify SHEET=, PROC IMPORT reads the first spreadsheet in the file. You may replace the equals sign with a blank.
Featured in: Importing an Excel Spreadsheet


Statements for DBMS Tables
The following data source statements are available to establish a connection to the DBMS when you import a DBMS table.

DATABASE="database"
specifies the complete path and filename of the database that contains the specified DBMS table. If the database name does not contain lowercase characters, special characters, or national characters, you can omit the quotes. You may replace the equals sign with a blank.

Note:   A default may be configured in the DBMS client software; however, the SAS System does not generate a default value.  [cautionend]
Featured in: Importing a Microsoft Access Table

DBPWD="database password"
specifies a password that allows access to a database. You may replace the equals sign with a blank.
Interaction: DBPWD= cannot be used with PWD=.
Featured in: Importing a Microsoft Access Table

MEMOSIZE=field-length
specifies the field length for importing Microsoft Access Memo fields.
Range: 255-32,767
Default: 1024
Tip: To prevent Memo fields from being imported, you can specify MEMOSIZE=0.

PWD="password"
specifies the user password used by the DBMS to validate a specific userid. If the password does not contain lowercase characters, special characters, or national characters, you can omit the quotes. You may replace the equals sign with a blank.

Note:   The DBMS client software may default to the userid and password that was used to log in to the operating environment; the SAS System does not generate a default value.  [cautionend]
Interaction: PWD= cannot be used with DBPWD=.
Featured in: Importing a Microsoft Access Table

UID="userid"
identifies the user to the DBMS. If the userid does not contain lowercase characters, special characters, or national characters, you can omit the quotes. You may replace the equals sign with a blank.

Note:   The DBMS client software may default to the userid and password that was used to log in to the operating environment; the SAS System does not generate a default value.  [cautionend]
Featured in: Importing a Microsoft Access Table

WGDB="workgroup-database-name"
specifies the workgroup (security) database name that contains the USERID and PWD data for the DBMS. If the workgroup database name does not contain lowercase characters, special characters, or national characters, you can omit the quotes. You may replace the equals sign with a blank.

Note:   A default workgroup database may be used by the DBMS; the SAS System does not generate a default value.  [cautionend]
Featured in: Importing a Microsoft Access Table


Security Levels for Microsoft Access Tables

Microsoft Access tables have three levels of security, for which specific combinations of security statements must be used.
None
Do not specify DBPWD=, PWD=, UID=, or WGDB=.

Password
Specify only DBPWD=.

User-level
Specify only PWD=, UID=, and WGDB=.

Each statement has a default value; however, you may find it necessary to provide a value for each statement explicitly.


Chapter Contents

Previous

Next

Top of Page

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