Chapter Contents |
Previous |
Next |
SAS/ACCESS Software for PC File Formats: Reference |
As in the Import/Export facility, the IMPORT and EXPORT procedures transfer data between SAS and external data sources. These external data sources can include DBMS tables, PC files, spreadsheets, and delimited external files, which are files containing columns of data values that are separated by a delimiter such as a blank or a comma.
IMPORT Procedure |
The syntax for the IMPORT procedure is shown here briefly but is described in detail in theSAS Procedures Guide.
PROC IMPORT
DATAFILE=<"filename" | TABLE="tablename"> OUT=<libref.> SAS-data-set <DBMS=identifier> <REPLACE>; <data-source-statements;> |
After you invoke the IMPORT procedure, it reads the input file and writes the data to a SAS data set, where the names of the SAS variables are based on the column names of the input data. PROC IMPORT imports the data by one of the following methods:
You control the results with options and statements that are specific
to your input data source. PROC IMPORT produces the specified output SAS data
set and writes information about the import to the SAS log. In the log, you
see the DATA step or the SAS/ACCESS code that is generated by PROC IMPORT.
If a translation engine is used, then the code is not submitted.
This example imports a Microsoft Access table called CUSTOMERS and from it creates a permanent SAS data set named SASUSER.CUST. The MS Access table has user-level security and, therefore, you need to specify the following statements: PWD=, UID=, and WGDB=. This example is repeated from the SAS Procedures Guide; see it for the following example's output and SAS log.
proc import table="customers" out=sasuser.cust dbms=access; uid="thomas"; pwd="rocket"; database="c:\hrdiv\east.mdb"; wgdb="c:\winnt\system32\security.mdb"; proc print data=sasuser.cust; run;
EXPORT Procedure |
The syntax for the EXPORT procedure is shown here briefly but is described in detail in the SAS Procedures Guide.
PROC EXPORT
DATA=<libref.>SAS-data-set OUT="filename" | OUTTABLE="tablename" <DBMS=identifier> <REPLACE>; |
The EXPORT procedure reads data from a SAS data set and exports it to an external data source by using one of the following methods:
The following example exports a SAS data set named MYFILE.CLASS and creates a delimited external file called CLASS. Notice that the DELIMITER= statement specifies the ampersand (&) delimiter to separate the column names in the new file. This example is repeated from the SAS Procedures Guide; see it for the following example's SAS log.
proc export data=myfiles.class outfile="/myfiles/class"; dbms=dlm; delimiter='&'; run;
PROC EXPORT produces an external file as follows (showing the first five rows):
NAMES&SEX&AGE&HEIGHT&WEIGHT Alice&F&13&56.5&84 Becka&F&13&65.3&98 Gail&F&14&64.3&90 Karen&F&12&56.3&77 Kathy&F&12&59.8&84.5
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.