Export a SAS Data Set into Excel spreadsheetYou often need to export the data set into an Excel spreadsheet.
This can be done easily by using a procedure called PROC EXPORT.
Example
Proc Export Data=Income
OutFile='/folders/myfolders/Income.xls'
Replace
Dbms=xls;
Run;
[Note: The code above might get cut off due to shortened screen width. Expand the web page for this session if needed.]
Proc Export is a procedure that allows you to export SAS data set into an external file such as Excel spreadsheet or Text file.
You should include these 3 options when using Proc Export:
1. OUTFILE option
The OUTFILE option lets you specify the exporting file. In our example, the data is exported into Income.xls.
2. REPLACE option
The REPLACE option allows you to overwrite the exporting 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 type of file for the exporting file. In our example, we use the DBMS option to tell SAS to export the data set into an Excel spreadsheet (xls).
----
Now, run the code from the example above.
The INCOME data set (created from one of our previous exercises) will then be exported into an Excel spreadsheet:
Exercise
Locate the ELECTRIC data set from 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?
HINT:
Remember to use the Library Reference when referring to a data set in a permanent library.
SOLUTION:
Proc Export Data=SASHelp.Electric
OutFile='/folders/myfolders/Electric.xls'
Replace
Dbms=xls;
Run;
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |