Creates a SAS table from an external file
|
name=IMPORT(table-name,file<,'DEFINE'>);
|
-
name
-
contains the name of the last SAS table
that was created.
Type: Character
-
table-name
-
is the new SAS table to create. If the
table already exists, a warning message is displayed when the IMPORT window
opens.
Type: Character
-
file
-
is the fileref or physical filename of the
external file from which data are to be imported. A physical filename must
be enclosed in quotation marks. (See the example.)
Type: Character
-
'DEFINE'
-
specifies to open the DEFINE window before
opening the IMPORT window.
Type: Character
- CAUTION:
- Blank lines in files can cause problems.
Under some host operating systems,
blank
lines in an external file may adversely affect the ability of the IMPORT function
to extract data from the file.
![[cautend]](../common/images/cautend.gif)
The IMPORT function returns the name of the last SAS
table that it created from an external data file. This function enables users
to easily import raw data from an external file into a SAS table.
Two auxiliary windows are associated with IMPORT: the
IMPORT window and the DEFINE window.
The IMPORT window, which defines the columns for the
SAS table, is the primary window for the IMPORT function. The first two lines
of the external file are displayed below a ruler in order to help the application
user identify the variables for the columns.
If numbers for start and end columns are not supplied,
then list input is used, and items in the file must be separated by at least
one blank. Users can use the following fields in the IMPORT window to specify
information about the table columns:
-
Name
-
specifies the name for the table column.
This can be any valid SAS name that is up to 32 characters long.
-
Start/End Column
-
specify the starting and ending columns
of the value in the external file. These fields are optional. You can specify
a starting column without specifying an ending column but not vice versa.
If you omit the ending column, it is calculated to be one less than the next
starting column.
-
Type
-
specifies the data type of the table column.
Choose the type by pressing ENTER or clicking with the mouse on the appropriate
type.
-
Format
-
specifies a SAS format. Enter a '?' to
display a list of some common formats. This field is optional.
-
Informat
-
specifies a SAS informat. Enter a '?' to
display a list of some common informats. This field is optional.
-
Label
-
specifies a label for the table column.
The label can be up to eight characters long. This field is optional.
The File menu enables you to perform save operations,
to import data with the Import Wizard, to export data using the Export Wizard,
to perform print operations, to send mail, and to close the window.
The Edit menu enables you to copy marked text, to select
or deselect marked text, to set the horizontal and vertical scroll amounts,
to perform find operations, and to set the keyfield (the field to search with
the next Find command).
The View menu enables you to scroll right and left,
to specify the sort order for fields in the window, to display the first record
in hexadecimal representation, and to open other SAS windows.
The Tools menu enables you to specify conditions for
querying values in the file, to open a Viewtable window, and to run a session
of graphics editors, the Report Editor or Text Editor. You can also set a
variety of options.
The Data menu enables you to create a SAS table from
contents of the external file, to test read the file, to define fields with
the Define window, to specify a different external file for input, to specify
a new name for the SAS table to create, to display the length of the longest
record that has been read, to view the external file, and to edit or browse
the data set that was created from the external file.
The DEFINE window is displayed when you use the DEFINE
option with the IMPORT function or when you select
| Data |
![[arrow]](../common/images/arrow.gif) |
Define fields |
from the IMPORT
window. It displays the first line from the external file, along with a ruler
and delimiter lines. On the delimiter lines, you can use < and > to mark
the beginning and end of a column, respectively. If the column is only one
character wide, use a vertical bar (|).
In order to use the DEFINE window, you must align the
data values in columns in the data records.
When you issue the END command to exit from this window,
the fields are given default column names and types (numeric or character).
The IMPORT window then opens so that you can change the column names and
optionally add formats and informats.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.