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 webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 1490 views
  • 0 likes
  • 3 in conversation