Data Set [12-14]

Export a SAS Data Set into an Excel spreadsheet

You will often need to export a data set into an Excel spreadsheet. 

This can be done easily by using a procedure called PROC EXPORT


Proc Export Data=Income 

[Note: you must change the directory path when running the code above.] 


Proc Export is a procedure that allows you to export a SAS data set into an external file such as an Excel spreadsheet or a text file. 

You should include these three options when using Proc Export:

1. OUTFILE option
The OUTFILE option lets you specify the file to be exported. In our example, the data is exported into Income.xlsx

2. REPLACE option
The REPLACE option allows you to overwrite the file if it already exists in the stated directory path. It is recommended to always include this option when using PROC EXPORT.

3. DBMS option
The DBMS option specifies the file format (file type) to be exported. In our example, we use the DBMS option to tell SAS to export the data set into an Excel spreadsheet (.xlsx). 


Now, run the code in the example above with your own directory path.

The Income data set (created in one of our previous exercises) will then be exported into an Excel spreadsheet:



Locate the Electric data set in the SASHelp library.

Export Electric into an Excel spreadsheet.

Ensure the Excel spreadsheet contains the same rows and columns as the SAS data set.

Need some help?

Get Hint

Get Solution