Basically, you will need to make sure that you issue the right content/type header (MIME header) for your content, using the STPSRV_HEADER function in a data null. You also need to make sure you have a working SAS program to convert to a stored process. Usually, you do NOT use or need other ODS statements in your stored process code. So I would recommend removing the statements highlighted below:
ods listing close; <----may not need this statement
depending on why it is here
ods html; <----delete this statement
ods html close; <----delete this statement
That's because %stpbegin/%stpend really take the place of your typical ODS "sandwich" statements. The value for &_ODSDEST is set appropriately by the client application. So, for EG, the SP would return HTML results; for PPT, the SP would return SAS Report XML results.
If you want to control the default output type (which is HTML by default for the IDP), then you would need to do an override to the reserved macro variable &_ODSDEST. If, for example, you wanted to generate a CSV file or an MSOFFICE2k HTML file or a TAGSETS.EXCELXP (Spreadsheet Markup Language XML file), you could override &_ODSDEST for the Portal execution of the SP by doing this BEFORE the %stpbegin:
%let _odsdest = msoffice2k;
To launch Excel when the results come back to the client browser, you'll still need the correct content/type header using the STPSRV_HEADER function, but this should get you started.
This SGF paper http://www2.sas.com/proceedings/forum2008/024-2008.pdf
talks about the basics of converting your programs to be stored processes -- it doesn't talk about STPSRV_HEADER, but it does go through the rest of the process. For more help with your stored process, you might consider contacting Tech Support for help.
Your stored process should have created an HTML file that conforms to the Microsoft HTML specification (MSHTML). When you use ODS to create a file, you are NEVER creating a "binary" .XLS format file. You are either creating an HTML file or an XML file or a CSV file that Excel can open.
If you use ODS CSV, then you create a CSV file; if you use ODS HTML or ODS MSOFFICE2K then you are creating an HTML file; if you use ODS TAGSETS.EXCELXP, then you are creating a Spreadsheet Markup Language XML file.
The STPSRV_HEADER function is merely telling the operating system, what application should be used to view the content that is coming down the HTTP pipeline from the execution of the stored process.
When I run either of these stored processes on my system, using the SAS Information Delivery Portal, my operating system (Windows XP) does successfully launch Excel:
Stored Process Version 1:
rc = stpsrv_header('Content-type',"application/vnd.ms-excel");
rc = stpsrv_header('Content-disposition',"attachment; filename=ex1.xls");
proc print data=sashelp.class noobs;
title 'test html _webout to Excel';
ods tagsets.msoffice2k close;
When I tested these 2 stored processes, BOTH of them successfully executed my stored process from the SAS Info Delivery Portal and my system launched Excel.
Can you test something more similar to my code instead of using your Macro program? If something simple like this does not launch Excel, then it's either that you are receiving the results on a machine that does not have Excel (like Unix or Linux) or there is something else wrong....perhaps a popup blocker that is blocking the "download/open" message that pops up or something else... which would mean a call to Tech Support.
I can only think of a few things.
-- you are trying to run/test this code from a local SAS session -- where there is no "connection" or plumbing for the BI Platform -- so you get the error message for _WEBOUT -- once you have converted your program to be a stored process with the STPSRV_HEADER and %STPBEGIN/%STPEND, you can no longer submit the program from your single user session -- you have to put the code in the source code repository and register the SP with the metadata and then test running the SP from the Portal.
-- you are using PUT statements to _WEBOUT with the FILENAME statement.
(In stored processes, if you are writing to _WEBOUT using PUT statements while ODS has _WEBOUT
open, when you execute the code the PUT statement data might be out of sequence with the data that is
generated by ODS. This problem occurs because both your code and ODS are opening the same fileref at
the same time.
This is the point at which you should consider contacting Tech Support for more help. They can gather your configuration and Stored Process information and double check that you are using the correct method and STPSRV_HEADER to launch Excel when the stream comes back from the Stored Process server. They can double check that you are using the Portal the right way or using the Stored Process Web Application.
I'm pretty sure that with MSOffice2K you only get a reference to the image file; it is not embedded in the document.
If you have a Web server or other network-accessible drive, you can alter your SAS code to store the image there, and then make sure that the URL in the HTML file is correct. This is not an optimal solution because you must maintain the generated image files.