BookmarkSubscribeRSS Feed
Quentin
Super User

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.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Lisa Mendez & Richann Watson present Get Tipsy with Debugging Tips for SAS® Code: The After Party on Wednesday Jul 16.
Register now at https://www.basug.org/events.
2 REPLIES 2
Cynthia_sas
Diamond | Level 26

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

macroCharlie
Calcite | Level 5

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1668 views
  • 0 likes
  • 3 in conversation