BookmarkSubscribeRSS Feed
mathias
Quartz | Level 8

Hello,

 

I have a (huge) Stored process that can make lots of graphs depending on the parameters.

These graphs are outputted in ods html PNG format + non-embedded titles & footers, + a few other proc prints in general.

 

Now  I need to make a version that outputs only 1 image, (the main png that is written in an img tag in the html output)

 

e.g.

  1. <img alt="The SGPlot Procedure" src="/SASStoredProcess/guest?_sessionid=3C3AC7BA-A50D-4BB7-8443-9DDB59150B04&_program=replay&_entry=APSWO..." style=" height: 480px; width: 640px;" border="0" class="c">
  2. /SASStoredProcess/guest?_sessionid=8E7E4609-4B45-4A95-8614-E6B4764FEC2E&_program=replay&_entry=APSWORK.TCAT0005.SGPlot.png
  3. /SASStoredProcess/guest?_sessionid=E21CFA30-10DC-4335-9540-601574329008&_program=replay&_entry=APSWORK.TCAT001A.SGPlot.png

 

What do you think would allow me to do that easily ?

 

I'm thinking adding a flag paramter to the STP

and then add a rule at the end of the STP that replaces the output 

I don't see anything else than an _webout 

with just the img tag maybe ?

, or just the png and changing the Content-type header ?

 

 

The idea would then to use it in an iframe

 or retrieve the src url and inject in a proper img tag with ajax maybe (but then I would probably face Cross-Origin Read Blocking (CORB) errors) 

 

Can I retrieve the _sessionid and the _entry that change every time the STP is called?

 

 

4 REPLIES 4
mathias
Quartz | Level 8

I think the _entry from the url

can be retrieved from _tmpcat in the stp

 

And the _sessionid can be found in _REPLAY

boemskats
Lapis Lazuli | Level 10

I'll have a think about this. In the meantime -

 

Be mindful that using session IDs in your STP code like that, even temporarily, will completely circumvent load balancing at the spawner, meaning that all of your users will be redirected to the same multibridge session & that part of your application will have a concurrent capacity of 1 user. See @Vince_SAS's reply here for details. This also risks destabilising the spawner and the JVM if you're using a guest account and are intending to have this as public-facing or high-throughput app with users queuing for the session.

 

I'm sure there's a better way...

mathias
Quartz | Level 8

I got a simple version working. like this:

 

%let plotPath = &_tmpcat ; 
ods html 
	path=&plotPath
	style=xxx
	image_dpi=400
	device=png;

* proc sgplot ;

data _null_;
	file _webout;
	put '<img style="width:100%" src="https://xxx.xxx.be' &_REPLAY 'SGPlot2.png" >';
	run;

I could not make the STP output a binary png file yet, so I had to output html img tag.

 

But you are right I'm afraid 😕

If I make several iframes pointing to this STP, they load one at a time (sometimes worse, a few will encounter errors).

So it's definitely not usable on a public-facing website.

 

(I don't know anything about load balancing, I think we always have 1 process at a time on our sas jboss server.)

 

 

 

Vince_SAS
Rhodochrosite | Level 12

Is the goal to return an image file to the client, without any HTML?  If so then create a streaming stored process and use this exact code (no STPBEGIN/END) with SAS/GRAPH procedures:

 

goptions devide=png gsfname=_webout;

proc gchart data=sashelp.class; vbar age / discrete; run; quit;

 

Use this exact code (no STPBEGIN/END) with SG procedures:

 

ods graphics on / imagefmt=png;

filename temp temp;

ods _all_ close;

ods html file=temp gpath=_webout;

proc sgplot data=sashelp.class; hbar age; run; quit;

ods html close;

 

Vince DelGobbo

SAS R&D

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1606 views
  • 1 like
  • 3 in conversation