Chapter Contents

Previous

Next
Getting Started with the SAS System Using SAS/ASSIST Software

Importing Data from a Flat File

Importing data enables you to read data from an existing external file and create a SAS table from it. In this section, you import the file that was created in the previous section. Note that when you import a file using SAS/ASSIST software, the file must be in fixed column format.


Instructions

  1. To import data from an external file, follow this selection path:

    Tasks
    [arrow]
    Data Management
    [arrow]
    Import Data...
    The Import Data from Flat File window appears.

    Import Data from Flat File Window

    [IMAGE]

  2. Select Data file to import. The Select External File Name window appears.

    Select External File Name Window

    [IMAGE]

  3. In the External file name field, type the name of the external file that you created in Exporting a File. Use the operating environment guidelines shown in Examples of Operating Environment-Specific Physical Pathnames (where USERID represents your userid). For this example, use the external file HOUSDATA.

  4. Select Filename to indicate that you typed the physical file name of the file.

  5. Select OK. The Import Data from Flat File window reappears.

  6. Select Output table. The Specify Output Table window appears.

    Specify Output Table Window

    [IMAGE]

  7. Type the name of the SAS table that you want to create using the data from the external file. For this example, type EXTHOUSE. Refer to SAS Tables for information about table naming.

    You can store the data temporarily or permanently. For this example, store the data temporarily.

  8. Select OK. The Import Data from Flat File window reappears.

  9. Select OK. The Define Fields window appears.

    Define Fields Window

    [IMAGE]

    The first line of the external file appears below the rule line. Notice that there is no space between the number of bathrooms (1) and the address (Sheppard Avenue). In fact, there are no spaces between any of the columns because you saved this file with fixed column widths rather than with delimiters between data values. Because numeric columns are right-justified, while character columns are left-justified, the data values in the bathrooms column appear to be directly adjacent to the data values in the address column. Be careful not to mark them as one data value.

  10. In the Define Fields window, use angle brackets (< and >) to mark the width of each field as shown in the following display. If a field has a length of only 1, use the vertical bar (|) to mark it.

    Make sure you allow for the greatest width possible for each field value so that you do not inadvertently truncate some of your data.

    Define Fields Window with Fields Defined

    [IMAGE]

  11. Select OK. The Import window appears.

    Import Window

    [IMAGE]

  12. Type the following information for each column at the bottom of the window. Press TAB to move among the fields. To move to the next or previous column at the bottom of the window, use the scroll bar in the lower right corner of the window.

    Assigning Column Information
    Name Type Format Informat Label
    SQFEET NUM

    Square Feet
    BEDROOMS NUM

    Number of Bedrooms
    BATHS NUM

    Number of Bathrooms
    ADDRESS CHAR

    Street Address
    PRICE NUM COMMA9. COMMA9. Price of House

  13. After you finish typing the information for all the columns, follow this selection path:

    Data
    [arrow]
    Create Data Set...
    ("Data set" is another term for "table.") The Create Data Set... window appears with a prompt that asks whether you want to be prompted to enter new values for bad values or whether you want a report sent to the log. For this example, select VERIFY so that you will be prompted to correct any errors in the data as they are imported.

  14. Select OK. A message appears at the bottom of the window with the statistics of the number of records processed.

    [IMAGE]

  15. Press ENTER to clear the statistics. The Import window reappears. A note appears in the message area stating the number of observations (rows) and variables (columns) in the table.

    You can Edit created data set or Browse created data set from the Data menu on the menu bar.

  16. When you finish browsing or editing your table, follow this selection path to close the FSBROWSE or FSEDIT window:

    File
    [arrow]
    Close
    Then, follow this selection path from the Import window to return to the WorkPlace menu:

    File
    [arrow]
    Close


Chapter Contents

Previous

Next

Top of Page

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