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: Bart Jablonski and I present 53 (+3) ways to do a table lookup on Wednesday Sep 18.
Register now at https://www.basug.org/events.
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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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