Hi....
Some clarification...first of all, a stored process is executing SAS code on the server. It CAN create files (using permanent packages) either in a webDAV server or on the server file system. Typically, you do not consider a stored process to be "exporting" anything. The SP is returning results...typically, those results are tailored to the client that requested the SP to be executed.
There is a HUGE difference between running the SP with the SPWA and running the SP from within Web Report Studio, for example. Web Report Studio will not "accept" PDF or HTML results from a Stored Process. Web Report Studio only wants to accept SASReport format output from a stored process. Using the Portal and/or the Stored Process Web Application, you could generate either HTML, or CSV or PDF results and, assuming you had the correct STPSRV_HEADER, the SPWA would send your results back to the requesting browser and the browser would ask the operating system to use the application specified in the content-type header.
If you do not have the SAS Add-in for Microsoft Office, then, how are you going to execute your stored process? I ask, because your only choices would be to use SAS Enterprise Guide, SAS Web Report Studio, the SAS Information Delivery Portal or using the Stored Process Web Application (SPWA) or with a custom front end that you write yourself, perhaps using JavaBeans or a JSP to execute the stored process.
Assuming that you are executing your SP from the SPWA or the Portal, then you can issue the correct &_ODSDEST and/or STPSRV_HEADER change within a SAS Macro program.
If you look at this paper from the 2007 SAS Global Forum,
http://www2.sas.com/proceedings/forum2007/021-2007.pdf
I had a single starter program that produced 3 outputs and I wanted to convert it to a stored process. In the paper, my recommendation was that you actually make 3 separate stored processes, one for each destination (because of the variability of what kind of results would be "accepted" by each client application).
But, if you REALLY wanted 1 SP that would produce 1 type of output at a time for each request, then I have a macro program called %SETOPT that shows how to check what the user selected and issues the appropriate changes BEFORE
%STPBEGIN starts up. (shown in the paper as DEMO5_MACRO.SAS)
The only difference between what you want to do and what I'm doing in my program is that you would put your whole data _null_ program inside the appropriate %IF/%END section of code in the macro program. (shown on page 13 of the paper).
The final flow of your SP will be something like this:
[pre]
**** start of SP ****;
%macro setopt;
....use %IF statements here with DATA _NULL_ code inside each %IF/%END
....also set correct &_ODSDEST in the %IF section;
%mend setopt;
*ProcessBody;
%stpbegin; /* <------note that %stpbegin is all the way DOWN here */
%setopt; /* above is only the macro definition HERE is the macro pgm invocation */
...more code...;
%stpend;
*** end of SP ***;
[/pre]
The other reason for having 1 SP for each result type is that if you make 3 SPs to start, then you know EXACTLY what the correct DATA _NULL_ for STPSRV_HEADER is and what the correct options are for each result type that you want the stored process to return. This practice falls under my general rule of thumb that before you dive into macro coding, you have to have a working SAS program first.
cynthia