如何將 SAS dataset 匯出至 Excel

0
有安裝 SAS/ACCESS to PC Files 產品時
  • LIBNAME EXCEL 直接讀寫既有 Excel 檔案。SAS 與 Microsoft Office 需同為相同的 32-bit (或 64-bit) 應用程式。
LIBNAME myxls EXCEL PATH='C: mpprdsale.xls';
  • LIBNAME PCFILES –同 LIBNAME EXCEL 直接讀寫既有 Excel 檔案。但須使用 SAS PC Files Server
LIBNAME myxls PCFILES SERVER=localhost PATH='C:prdsale.xls';
  • PROC EXPORT DBMS=EXCELCS :使用SAS PC Files Server讀寫既有 Excel 檔案。

proc export dbms = excelcs data= sashelp.prdsale
outfile = "C:prdsale.xls "
replace;
server="localhost";
run;
  • PROC EXPORT DBMS=EXCEL產生 Excel 檔案。 SAS 與 Microsoft Office 需同為相同的 32-bit (或 64-bit) 應用程式。
proc export
data = sashelp.prdsale
dbms = excel
outfile = "c:prdsale.xls"
replace;
run;
  • PROC EXPORT DBMS=XLS : 產生 Excel XLS 檔案格式。無須使用 SAS PC Files Server。
proc export
data = sashelp.prdsale
dbms = xls
outfile = "c:prdsale.xls"
replace;
run;
  • PROC EXPORT DBMS=XLSX (SAS 9.3 M1 新功能):產生 Excel 2010 XLSX 檔案格式。無須使用 SAS PC Files Server。
proc export
data = sashelp.prdsale
dbms = xlsx
outfile = "c:prdsale.xlsx"
replace;
run;

若無 SAS/ACCESS to PC Files 安裝時

  • PROC EXPORT DBMS=CSV 產生 CSV (comma separated value) 檔案格式。
proc export
data = sashelp.prdsale
outfile = 'c: mpprdsle.csv'
dbms = csv
replace;
run;

此外,亦可使用下列方式產生 Excel 可讀取的檔案

  • ODS TAGSETS.CSV (http://support.sas.com/rnd/base/ods/excel/index.html)
  • ODS TAGSETS.EXCELXP (http://support.sas.com/rnd/base/ods/odsmarkup/excelxp_help.html)
  • FILENAME DDE (http://support.sas.com/documentation/cdl/en/hostwin/63047/HTML/default/viewer.htm#n1aqiv6biqkjbnn1gu1388hp7aab.htm
Tags
Share

About Author

SAS Taiwan

SAS 學習資源 : https://blogs.sas.com/content/sastaiwan/

Comments are closed.

Back to Top