SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2
Importing Data into a Data Set
The Import wizard guides you through the steps of importing data from many different file types into a SAS data set.
| Note | The types of files that can be imported depend on your operating system. |
If your data is not in a standard file format, you can use the External File Interface (EFI) facility to import data. This tool enables you to define your file format, and offers you a range of format options. To use the EFI, select User-defined formats in the Import wizard and follow the instructions for describing your data file. This example shows you how to import a standard file and view the results.
To import a standard file:
-
Select
to open the Import wizard. Notice that Standard data source is selected by default. Display 19-21: Import Wizard Window Displaying Default Values -
Click the drop-down arrow to see the list of data sources. If you exported data to Excel, select Excel 97 Spreadsheet (*.xls). Otherwise, select the file format in which your data are stored.
Display 19-22: Import Wizard Window Displaying List of Data Sources -
Click
to continue. -
In the Select File dialog box, type the full path for your file, or click
to find it. Display 19-23: Import Wizard File Selection Window -
Click
to continue. The Select library and member dialog box appears. Display 19-24: Import Wizard Library Selection Window -
Type WORK for the library name and MyImport for the member name.
-
Click
to continue. If you are importing data from the Excel 97 Spreadsheet format, you are asked about saving PROC IMPORT statements. Skip this option and click . Your data are imported into the SAS data set WORK.MyImport.
Exporting Your Data with the Export Wizard
You can easily export SAS data to a variety of file formats, using the Export Wizard. The formats that are available depend on your operating environment and on the SAS software products that you have installed. The example uses the PRDSALE data set that was created in a previous example (see "Copying a Practice File to the WORK Data Library" on page 307).
To export SAS data, do the following:
-
If it is not already open, double-click the WORK.PRDSALE data set to open it in the VIEWTABLE window.
-
Select
The Export Wizard window opens. Note that the LIBRARY and MEMBER lists contain the name of the data set (WORK.PRDSALE) that is currently displayed in the VIEWTABLE window. Display 19-25: Export Wizard Window Displaying Default Values -
Click
to proceed to selecting an export type. Notice that Standard data source is selected by default. In the data source list, select Tab Delimited File (*.txt) , or another format that is available on your operating environment. Display 19-26: Export Wizard Window Displaying List of Data Sources -
Click
and select a directory. -
Click
to proceed to selecting a destination file. -
Type the file name MYEXPORT and click
. -
Click
.
The SAS data set is exported to MYEXPORT in the directory that you selected.