BookmarkSubscribeRSS Feed
gyambqt
Obsidian | Level 7

Hello,
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.

%STPBEGIN;

ods html file="c:/a.html";

proc print data=a;

run;

ods html close;

 

%STPEND;

 

 

Thank you very much!!!


4 REPLIES 4
boemskats
Lapis Lazuli | Level 10

Hi,

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:

%STPBEGIN;

proc print data=a;

run;

%STPEND;

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.

Nik

gyambqt
Obsidian | Level 7

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?

Quentin
Super User

Hi,

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;

run;

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:

data _null_;

  file _webout;

  infile "%sysfunc(pathname(work))/a1.html";

  input;

  put _infile_;

run;

I blogged about this approach here:

http://bi-notes.com/2012/07/stored-process-ignore-log-your-own-peril/

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.

HTH,

--Q.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
boemskats
Lapis Lazuli | Level 10

Hah. Thanks for making me go have a look at it. Indeed you're right. And I did just learn a lot.  It's amazing for how long I managed to put off having a look at those.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 4 replies
  • 3856 views
  • 6 likes
  • 3 in conversation