Thursday, June 9, 2011

A SAS Stored Process Web Application that exports a Dataset to an Excel sheet

While creating Drill down reports, you might need to provide the users with the option of downloading the entire data to an excel sheet. For this you may need to create an interface(Code) where the Export button is displayed and a stored process that converts the Dataset to the excel sheet.



/******Code for Converting the data to excel ******/

data _null_;
rc=stpsrv_header('Content-type','application/vnd.ms-excel');
rc=stpsrv_header('Content-disposition','attachment; filename=temp.xls');
run;
ods tagsets.excelxp file=_webout style=sasweb options(embedded_titles="yes"
embedded_footers="yes"
print_header='&B&CThis is a test'
print_footer='&B&CThis is a footer printed on &D');
title "Export To Excel";
proc print data=&DSN ;
run;
ods tagsets.excelxp close;