Your SAS programs, embedded in web apps and elsewhere

Return SAS Dataset from Stored Process

Reply
PROC Star
Posts: 1,322

Return SAS Dataset from Stored Process

Hi All,

Short version:

What are the "best" way(s) to have a stored process called through SPWA return a SAS dataset to the user (as an attachment)?

Long version:

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.

Thanks,

--Q.

SAS Super FREQ
Posts: 8,868

Re: Return SAS Dataset from Stored Process

Hi:

  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.

cynthia

Occasional Contributor
Posts: 18

Re: Return SAS Dataset from Stored Process

Quentin

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:

sas.jpg

The template is used to keep quotes out of the file.

You can run this SP through a browser with a url like:

http://yourSPserver:8080/SASStoredProcess/do?_program=%2FShared+Data%2FYourFolder%2FExportQCResults

Charlie

Ask a Question
Discussion stats
  • 2 replies
  • 513 views
  • 0 likes
  • 3 in conversation