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-disposition','attachment; filename=temp.xls');
ods tagsets.excelxp file=_webout style=sasweb options(embedded_titles="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 ;
ods tagsets.excelxp close;