Thursday, April 25, 2013

To excel

Image and video hosting by TinyPic
Here are methods for exporting data to excel:
%let gd = your_file_storage_path; 

/* 1. proc export */
proc export data = eg
 dbms = excel
 outfile = "&gd.\eg_export.xls"
 replace; 
 sheet = "page1";
run; 

/* 2. libname */
libname here "&gd."; 
libname here excel 
"&gd.\eg_libname.xls" ver=2002;
data here.eg(dblabel=yes);
 set eg;
run; 
libname here clear;

/* 3. ODS tagset */
ods tagsets.excelxp
 file  = "&gd.\eg_tagset.xls"
 style = minimal
 options (Orientation = "landscape"
 FitToPage = "yes"
 Pages_FitWidth = "1"
 Pages_FitHeight = "100"); 
proc print data = eg NOOBS; 
run; 
ods tagsets.excelxp close; 

/* 4. ODS CSV */
ods csv file = "&gd.\eg_csv.csv";
proc print data = eg;
run; 
ods csv close; 

/* 5. ODS html */
ods html body = "&gd.\eg_html.xls";
proc print data = eg; 
run; 
ods html close; 

/* 6. ODS MSOFFICE2k */
ods tagsets.msoffice2k file = "&gd.\eg_msoffice2k.xls";
proc print data = eg; 
run; 
ods tagsets.msoffice2k close; 

/* 7. DDE */

/* 8. Integrated object model */

Image and video hosting by TinyPic

No comments:

Post a Comment