I am very new to stored process and my questions are below:
1.What is the key difference between stream and transient package output result. I have read through developer's guide about stored process. It said if you create a stored process using stream, the output result will be stored in a temporary file _WEBOUT and stream back to the client like enterprise guide. it seems there is no significant difference comparing with transient package where output returns a temporary package to the client.
2. What is the advantage of using each method (stream vs package)?
3.If I have specified the physical location of the file output to be saved like the following: and if you choose stream output, does it mean instead of saving the output result to the temporary file _WEBOUT, it will save the output result to this location as indicated follow: "c:/a.html" and not stream back to the client (like EG). Does it mean when you run the stored process on stored process server, you won't be able to see the result output on EG.
ods html file="c:/a.html";
proc print data=a;
ods html close;
Thank you very much!!!
Fom my experience the majority of Stored Processes tend to require 'streaming' output when it comes to using stored processes to display reports. The STPBEGIN and STPEND macros adjust the ODS output location for 'Streaming' output so that it is displayed correctly according to the client that you used to run your stored process. The 'package' output option lets you use your SAS code to create 'sas packages' which can contain things like a combination of datasets, html reports etc. which can then be consumed by the requesting client. In practice I think these are rarely used unless they form part of a specific solution workflow, or where you want to, for example, let your Enterprise Guide users create and download customised SAS datasets on-demand for analysis.
In your specific case, and with the code that you mentioned above, it sounds to me like you want to be using streaming output. Also, the %STPBEGIN and %STPEND macros will create and manage your ODS outputs for you, so you can skip these. So to make something like the code above work properly regardless of the client that executes your STP, select streaming output and do this:
proc print data=a;
Just as a side note, what you're proposing in your original code above wouldn't be considered by SAS as any kind of stored process 'output' - you would just be using the Stored Process server to run some code, as part of which you create an output file on disk somewhere. It's an output of the code you wrote, sure, but it's not considered stored process output in the context of the Stored Process Server.
This is a bit advanced but may make sense further down the line: SAS Stored Processes: Result Types
Hope this helps.
Thanks for your response Nikola.
As you have mentioned above, "'sas package output' can contain things like a combination of datasets, html reports etc". Does that mean if I choose 'streaming output', the output can only contains one type of output like either dataset or html reports, etc rather than a combination of them?
Also I am bit curious, if I use ods to define the location where the physical file (output) is saved. for example: ods html file="c:/example/a1.html", would the output be streamed back from "a1.html" rather than "_webout" file to client(like EG) if the codes is running on the stored process server?
I haven't done much with calling stored process from EG. I have worked more with calling stored processes from the web, using stored process web application.
For this, I have almost always used streaming results. With HTML, streaming results and the logical stored process server (as opposed to package results and workspace server) give you a lot of control, in my experience. You can set html headers, you can manually write an HTML file and stream it back to browser, you can do sessions, etc.
I have done stored processes like you describe where first I write an html (or pdf/rtf/excel) file to somewhere on the server, e.g.
ods html file="%sysfunc(pathname(work))/a1.html";
proc print data=sashelp.shoes;
ods html close;
and later in the code (often after some log checking), I manually stream the file back to the _webout, e.g. something like:
I blogged about this approach here:
One last point is that choice of streaming results vs. package results will also depend on client. For example, I think Web Report Studio can consume package results, but not streaming results.
One other last point is that there is no magic in %STPBEGIN(). Take a look in your autocall library to find it and look at what it does. You will learn A LOT.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.