The EXPORT Procedure

PROC EXPORT Statement


Featured in: All examples

PROC EXPORT DATA=<libref.>SAS-data-set <(SAS-data-set-options)>
OUTFILE="filename" | OUTTABLE="tablename"
<DBMS=identifier> <REPLACE>;

Required Arguments

DATA=<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, PROC EXPORT uses either the USER library (if assigned) or the WORK library (if USER not assigned).

Default: If you do not specify a SAS data set, PROC EXPORT uses the most recently created SAS data set, which SAS keeps track of with the system variable _LAST_. However, in order to be certain that PROC EXPORT uses the correct data set, you should identify the SAS data set.
Restriction: PROC EXPORT can export data only if the format of the data is supported by the data source or the amount of data is within the limitations of the data source. For example, some data sources have a maximum number of rows or columns, and some data sources cannot support SAS user-defined formats and informats. If the data that you want to export exceeds the limits of the data source, PROC EXPORT may not be able to export it correctly. When incompatible formats are encountered, the procedure formats the data to the best of its ability.
Restriction: PROC EXPORT does not support writing labels as column names. However, SAS does support column names up to 32 characters.
Featured in: All examples
(SAS-data-set-options)

specifies SAS data set options. For example, if the data set that you are exporting has an assigned password, you can use the ALTER=, PW=, READ=, or WRITE= data set option, or to export only data that meets a specified condition, you can use the WHERE= data set option. For information about SAS data set options, see "Data Set Options" in SAS Language Reference: Dictionary.

Restriction: You cannot specify data set options when exporting delimited, comma-separated, or tab-delimited external files.
Featured in: Exporting a Subset of Observations to an Excel Spreadsheet
OUTFILE="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 does not include special characters (such as the backslash in a path), lowercase characters, or spaces, you can omit the quotation marks. A fileref is a SAS name that is associated with the physical location of the output file. To assign a fileref, use the FILENAME statement. For more information about PC file formats, see SAS/ACCESS for PC Files: Reference.

Featured in: Exporting a Delimited External File, Exporting a Subset of Observations to an Excel Spreadsheet, and Exporting to a Specific Spreadsheet in an Excel Workbook
Restriction: PROC EXPORT does not support device types or access methods for the FILENAME statement except for DISK. For example, PROC EXPORT does not support the TEMP device type, which creates a temporary external file.
Restriction: For client/server applications: When running SAS/ACCESS software on UNIX to access data that is stored on a PC server, you must specify the full path and filename of the file that you want to import. The use of a fileref is not supported.
OUTTABLE="tablename"

specifies the table name of the output DBMS table. If the name does not include special characters (such as question marks), lowercase characters, or spaces, you can omit the quotation marks. Note that the DBMS table name may be case sensitive.

Requirement: When you export a DBMS table, you must specify the DBMS= option.
Featured in: Exporting a Microsoft Access Table

Options

DBMS=identifier

specifies the type of data to export. To export a DBMS table, you must specify DBMS= by using a valid database identifier. For example, DBMS=ACCESS specifies to export a table into a Microsoft Access 2000 or 2002 database. To export PC files, spreadsheets, and delimited external files, you do not have to specify DBMS= if the filename that is specified in OUTFILE= contains a valid extension so that PROC EXPORT can recognize the type of data. For example, PROC EXPORT recognizes the filename ACCOUNTS.WK1 as a Lotus 1-2-3 Release 2 spreadsheet and the filename MYDATA.CSV as an external file that contains comma-separated data values; therefore, a DBMS= specification is not necessary.

Tip: When you specify DBMS=XLS for an Excel file, you can read and write Excel spreadsheets under UNIX directly, without having to access the PC Files server.

The following values are valid for the DBMS= option:

Identifier Output Data Source Extension Host Availability Version of File Created
ACCESS Microsoft Access 2000 or 2002 table .mdb Microsoft Windows * 2000
ACCESS97 Microsoft Access 97 table .mdb Microsoft Windows * 97
ACCESS2000 Microsoft Access 2000 table .mdb Microsoft Windows * 2000
ACCESS2002 Microsoft Access 2002 table .mdb Microsoft Windows * 2000
ACCESSCS Microsoft Access table .mdb UNIX 2000**
CSV delimited file (comma-separated values) .csv OpenVMS Alpha, UNIX, Microsoft Windows
DBF dBASE 5.0, IV, III+, and III files .dbf UNIX, Microsoft Windows 5.0
DLM delimited file (default delimiter is a blank) .* OpenVMS Alpha, UNIX, Microsoft Windows
DTA Stata file .dta Microsoft Windows, UNIX Version 8
EXCEL4 Excel 4.0 spreadsheet .xls Microsoft Windows 4.0
EXCEL5 Excel 5.0 or 7.0 (95) spreadsheet .xls Microsoft Windows 5.0
EXCEL Excel 97, 2000, or 2002 spreadsheet .xls Microsoft Windows 97
EXCEL97 Excel 97 spreadsheet .xls Microsoft Windows * 97
EXCEL2000 Excel 2000 spreadsheet .xls Microsoft Windows * 97
EXCEL2002 Excel 2002 spreadsheet .xls Microsoft Windows * 97
EXCELCS Excel spreadsheet .xls UNIX 97**
XLS Excel spreadsheet .xls UNIX, Microsoft Windows Version 5.0 or later
PCFS Files on PC server .* UNIX
SAV SPSS file, compressed and uncompressed binary files .sav Microsoft Windows, UNIX
TAB delimited file (tab-delimited values) .txt OpenVMS Alpha, UNIX, Microsoft Windows
WK1 Lotus 1-2-3 Release 2 spreadsheet .wk1 Microsoft Windows
WK3 Lotus 1-2-3 Release 3 spreadsheet .wk3 Microsoft Windows
WK4 Lotus 1-2-3 Release 4 and 5 spreadsheet .wk4 Microsoft Windows

* Not available for Microsoft Windows 64-Bit Edition.** Value listed here is the default value. The real version of file loaded depends on the version of the existing file or the value specified for VERSION= statement.

Restriction: The availability of an output data source depends on
  • the operating environment, and in some cases the platform, as specified in the previous table.

  • whether your site has a license to the SAS/ACCESS software for PC file formats. If you do not have a license, only delimited files are available.

Featured in: Exporting a Delimited External File and Exporting a Microsoft Access Table

When you specify a value for DBMS=, consider the following for specific data sources:

REPLACE

overwrites an existing file. Note that for a Microsoft Access database or an Excel workbook, REPLACE overwrites the target table or spreadsheet. If you do not specify REPLACE, PROC EXPORT does not overwrite an existing file.

Featured in: Exporting a Subset of Observations to an Excel Spreadsheet and Exporting a Microsoft Access Table

space
Previous Page | Next Page | Top of Page