The EXPORT Procedure

The Basics of PROC EXPORT

Note: The EXPORT procedure is available for Windows, UNIX, or LINUX operating environments.
The EXPORT procedure reads data from a SAS data set and writes it to an external data source. In Base SAS 9.4, external data sources include delimited files and JMP files. In delimited files, a delimiter can be a blank, comma, or tab that separates columns of data values. If you have a license for SAS/ACCESS Interface to PC Files, you can also export to additional file formats, such as to a Microsoft Access database, Microsoft Excel workbook, DBF file, and Lotus spreadsheets.
The EXPORT procedure uses one of these methods to export data:
  • generated DATA step code
  • generated SAS/ACCESS code

PROC EXPORT Syntax

You control the results with options and statements that are specific to the output data source. The EXPORT procedure generates the specified output file and writes information about the export to the SAS log. The log displays the DATA step or the SAS/ACCESS code that the EXPORT procedure generates.
Syntax, PROC EXPORT statement:
PROC EXPORT DATA=<libref.>SAS-data-set
OUTFILE= “filename
<DBMS=identifier>;
<REPLACE>;
  • libref.SAS-data-set identifies the input SAS data set with either a one- or two-level SAS name (library and member name). If you specify a one-level name, by default, the EXPORT procedure uses either the USER library (if assigned) or the WORK library.
    Default: If you do not specify a SAS data set to export, the EXPORT procedure uses the most recently created SAS data set. SAS keeps track of the data sets with the system variable _LAST_. To be certain that the EXPORT procedure uses the correct data set, you should identify the SAS data set.
  • filename specifies the complete path and filename or a fileref for the output PC file, spreadsheet, or delimited external file.
    If you specify a fileref, or if the complete path and filename do not include special characters (such as the backslash in a path), lowercase characters, or spaces, you can omit the quotation marks.
  • identifier specifies the type of data to export. To export to a DBMS table, you must specify the DBMS option by using a valid database identifier. For DBMS=DLM, the default delimiter character is a space. However, you can use DELIMITER='char' statement within the EXPORT procedure to define a specific delimiter character.
  • REPLACE overwrites an existing file. If you do not specify REPLACE, the EXPORT procedure does not overwrite an existing file.
The following values are valid for the DBMS identifier:
Table 16.1 DBMS Identifiers Supported in Base SAS
Identifier
Output Data Source
Extension
CSV
Delimited file (comma-separated values)
.csv
DLM
Delimited file (default delimiter is a space)
JMP
JMP files, Version 7 or later format
.jmp
TAB
Delimited file (tab-delimited values)
.txt
The availability of an output external data source depends on these conditions:
  • the operating environment and, in some cases, the platform as specified in the previous table.
  • whether your site has a license for SAS/ACCESS Interface to PC Files. If you do not have a license, only delimited and JMP files are available.

Example: Exporting a Subset of Observation to a CSV File

This example exports the SAS data set Cert.Leukemia to a delimited file.
proc export data=cert.leukemia (where=(survived=1))  /*#1*/
  outfile="C:certleukemia_surv.csv"                /*#2*/
  dbms=csv                                           /*#3*/
  replace;                                           /*#4*/
run;
1 The DATA= option specifies the input file. The WHERE option requests a subset of the observations.
2 The OUTFILE= option specifies the output file.
3 The DBMS= option specifies that the output file is a CSV file
4 The REPLACE option overwrites an existing file.
The EXPORT procedure produces this external CSV file:
Output 16.2 CSV File
CSV File
Last updated: February 14, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset