The SAS Output Delivery System and reporting techniques

Output excel file is not generating from stored procedure created using SAS EG

Occasional Contributor
Posts: 12

Output excel file is not generating from stored procedure created using SAS EG

Hello everyone,


Again i am hit with one strange error.


I am creating a report using sas stored procedure to get the ouput in excel spreadsheet from running this stored procedure from web application. while i have used same code which i have used in previous reports and those are giving result absolutely fine.


I am using below code:


data _null_;

 rc = stpsrv_header('Content-disposition','attachment; filename=test.xls');

 rc = stpsrv_header('Content-disposition',"inline");




/*ods tagsets.ExcelXP options(*/






sheet_name='Current Data'

/*autofilter='ALL' */

/*frozen_headers='3' */

/*frozen_rowheaders='NO' */




/*ZOOM='80' */




%let _ODSSTYLE=seaside;


Then MACRO Code to run report.


I am getting below error rather than getting output in excel file.


<?xml version="1.0" encoding="utf-8" ?>

  <?mso-application progid="Excel.Sheet"?>
- <!--
 Generated by the SAS Excelxp Tagset .v1.131, 04/23/2015 
- <Workbook xmlns="urn:schemas-microsoft-comSmiley Surprisedffice:spreadsheet" xmlns:x="urn:schemas-microsoft-comSmiley Surprisedffice:excel" xmlns:ss="urn:schemas-microsoft-comSmiley Surprisedffice:spreadsheet" xmlns:html="">
- <DocumentProperties xmlns="urn:schemas-microsoft-comSmiley Surprisedffice">
  <Company>SAS Institute Inc.</Company>
- <Styles>
- <Style ss:ID="_body">
Can anyone suggest what should i do to get rid of this and get output in excel spreadsheet.
Thanks in advance !!
Super User
Posts: 9,548

Re: Output excel file is not generating from stored procedure created using SAS EG

What you get is Excel-compatible XML. Saving that as a .xml file and opening with Excel should work.


Do not name output created with tagsets.excelxp with a .xls extension, as you are not creating an Excel file, but XML text. It's just that the XML contains Excel-compatible data.


You also can't have both content-dispositions (see The second overrides the first and directs your browser to display the XML text inline, which it dutifully does. If you only have "attachment" (and use the CORRECT extension .xml!!), the browser will then prompt you for storing or opening the file.


Alternatively, consider using another means of transfer to Excel, like proc export with the xlsx engine.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation