09-28-2012 02:05 PM
What are the "best" way(s) to have a stored process called through SPWA return a SAS dataset to the user (as an attachment)?
I have a big SAS dataset, and want to write a stored process that will let users build their own data extracts. Basically it will be a query tool. User will pass a few parameters for a WHERE statement, and specify to return the file as a csv, .xls, or .sas7bdat. When the stored process runs, it should pop up the open/save dialog box. Stored Proces will be called through SPWA.
For the csv file I assume I will just use ods CSV writing to _webout (after the appropriate stpsrv_header calls).
And since I don't need any formatting in the Excel sheet, I think for Excel my first shot would be just returning a csv file, with an .xls extension and stpsrv_header telling IE to open it in Excel. I don't need any of the pretty reporting stuff that comes with tagsets.ExcelXP, as this is data, not a report.
But I'm not sure how to send back a SAS dataset. One thought was to try using a data _null_ step to stream back the .sas7bdat file, as in: http://support.sas.com/kb/6/588.html. I've used that approach for streaming a pdf report, and it has worked well.
But maybe I would be better off looking into how to send this as a package instead?
Would appreciate any suggestions/recommendations.
09-28-2012 02:33 PM
If I had to do this, I would send it as a package. In a previous posting, the Tech Support note put multiple different outputs in the package, including a SAS dataset. I think it is a far "cleaner" method to return results to the stored process consumer.
12-18-2012 10:45 AM
This is a way I found after looking through lots of info on it through the internet.
I use the session headers to return a dataset from a permanent library. The dataset is created from another SP that is run before this one:
The template is used to keep quotes out of the file.
You can run this SP through a browser with a url like: