BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mathias
Quartz | Level 8

Hello,

I have a STP creating PNG images and a _webout html page.

I'm searching where I should put the PNG images in order to link to them in the _webout html page with relative links :

<img src="graphs/spatioTempo/time_BRR_SP.png"/>

-------------------------------------------

Just in case, here is the code used for creating the images.

        ods graphics / reset imagename="&name";

        goptions reset=all  device=png gsfname=graphout cback=white;

        ods _all_ close;

        ods html file='map.html' path=&plotPath style=wivisp_sasstyle;

            * Unused plot for setting increment naming count to 1;

            proc sgrender data=&Data template=&template object=object;

                dynamic title="no by";

                run;quit;

            * Actual plots ;

            proc sgrender data=&Data template=&template object=object;

                dynamic title="Spatial distribution of &selectgerm for a period of one &timeFrame starting at";

                by &by;

                run;quit;

                ods html close;

                * back to normal ;

                ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=wivisp_sasstyle NOGTITLE NOGFOOTNOTE GPATH=&sasworklocation ENCODING=UTF8 options(rolap="on");

Thank you very much for your time,

Regards,

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Hi,

This seems to work for me.  Not sure it solves the same problem you are trying to solve.

I use ODS HTML to generate a .png file saved (I guess) in &_tmpcat.

Then in a _null_ step writing to _webout I use &_replay.myimage.png in the path, after dequoting &_replay.

Maybe this is a start???

ods _all_ close;

ods graphics / reset imagename="myimage" ;

ods HTML

  body="%sysfunc(pathname(work))/nouse.html"

  path=&_tmpcat (url=&_replay)

;

proc sgplot data=sashelp.class;

  scatter x=height y=weight;

run;

ods html close;


%let _replay=%qsysfunc(dequote(&_replay));

%put _replay is: >>>&_replay<<<;

data _null_;

  file _webout;

  put "<html>";

  put "I am some text";

  put "<img src=""&_replay.myimage.png"">";

put "</html>";

run;

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.

View solution in original post

15 REPLIES 15
Quentin
Super User

I'm confused, you said you are writing to _webout, but your sample code writes to a file (map.html).

If you use %STPBEGIN / %STPEND, it handles the temporary locations for image files for you, ie it sets the value of PATH option on the ODS HTML statement.

Is there a reason you're not using them?  They tend to make life easier.

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.
mathias
Quartz | Level 8

That map.html is not used, it's a by-product of ODS html which i cannot get rid of.

I'am not using %stbegin because then _webout file is locked and cannot be writen.

Quentin
Super User

Maybe show more of your code.

do you have an:

ods html file= _webout

later?

or a data _null_  step writing to _webout?

After calling %STPBEGIN  _webout is locked because you can only have one ODS sandwich writing to _webout.

If you are basically generating your own custom html, and using a _null_ step to send it to _webout, then I would think you could put your images anywhere....  But it's be trickier, cuz with %STPBEGIN it handles the links for you, and writes the images to a temp catalog where they are replayed from ....

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.
mathias
Quartz | Level 8

I'am using a data _null_ file=_webout step, yes. (to be able to write a complex html page with css and javascript)

I can put my images anywhere I believe.

I put them on a webserver for now, but this webserver is protected with my login, while the STP is run anonymously by webanon. So the STP cannot write or read the images for now and this is why I'am looking for another path, common to my ods output and my _webout page.

Is is possible to know where the _webout html file is ? we have 1 jboss and 1 sasbi machines to run the STP.

(in other words, if i write <img src="test.png" />, where do I need to put test.png ?)

Quentin
Super User

Sorry, I don't think I'm going to be of much help.  Was hoping something like below might work, but I don't think I'm even close....  Also played a bit with &_tmpcat.  I would think that might be a better approach, i.e. diggging into how the "light weight sessions" work, and trying something similar.  But that's just a guess.

ods _all_ close;
ods graphics / reset imagename="myimage" ;

ods html body='nouse.html'
  path="%sysfunc(pathname(work))"
  gpath="%sysfunc(pathname(work))"
;

proc sgplot data=sashelp.class;
  scatter x=height y=weight;
run;
ods html close;

data _null_;
  file _webout;
  put "";   put "I am some text";   put "";   put ""; run;
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.
mathias
Quartz | Level 8

I tried

_TMPCAT=APSWORK.TCAT01F2

Images are created, but I have no idea where.

Isn't work going to be purged before you have the chance to load the html ?

I think the images have to be stored permanently to solve my problem, since My HTML code shows only 1 image and then uses javascript to load others.

$('#timeplot').attr('src', 'graphs/spatioTempo/time_BRR_SP' + frameCounter + '.png');

What about storing them in the folder where the STP is ?

_PROGRAM=/Epistat/SP/STP_SPATIOTEMP

_METAFOLDER=/Epistat/SP/

Quentin
Super User
ods HTML
  body="%sysfunc(pathname(work))/nouse.html"
  path=&_tmpcat (url=&_replay)
;

proc sgplot data=sashelp.class;
  scatter x=height y=weight;
run;
ods html close;

%let _TMPCAT=&_TMPCAT..myimage.png;

I played with aboeve, I think came close to getting it working, but could be a blind alley.

So idea is images are written to &_tmpcat (I don't know where that is).

Then image tag looks like:

  put "<img src='"&_replay"'>";

And I've already added the name of the image to &_TMPCAT.

THat was basically looking at html code generated by %STPBEGIN and trying to replicate it. (i.e., use the lightweight session)

Feels close, but could be wrong.  If I have time tonight, will play some more.  Unless Vince or somebody jumps in with a solution first (hopefully!)

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.
mathias
Quartz | Level 8

Thanks a lot for all your work Quentin

I tried your code. (changed this : put "<img src="&_replay">"; )

It produces this html :

<img src="/SASStoredProcess/guest?_sessionid=9976D03A-1ED9-4A1E-A629-77B2448EB6DF&_program=replay&_entry=APSWO...">


but this img tag does not work

Quentin
Super User

Hi,

This seems to work for me.  Not sure it solves the same problem you are trying to solve.

I use ODS HTML to generate a .png file saved (I guess) in &_tmpcat.

Then in a _null_ step writing to _webout I use &_replay.myimage.png in the path, after dequoting &_replay.

Maybe this is a start???

ods _all_ close;

ods graphics / reset imagename="myimage" ;

ods HTML

  body="%sysfunc(pathname(work))/nouse.html"

  path=&_tmpcat (url=&_replay)

;

proc sgplot data=sashelp.class;

  scatter x=height y=weight;

run;

ods html close;


%let _replay=%qsysfunc(dequote(&_replay));

%put _replay is: >>>&_replay<<<;

data _null_;

  file _webout;

  put "<html>";

  put "I am some text";

  put "<img src=""&_replay.myimage.png"">";

put "</html>";

run;

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.
Quentin
Super User

Just saw your most recent post.  I think that image tag doesnt work becauase of the trailing dot.  Thus I ended up mucking withh %dequote to remove the quotes and add them back myself later.

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.
mathias
Quartz | Level 8

I saw that annoying point and was trying to remove it with tranwrd.

But your solution works.

So i'll try to adapt it to work with my case and I'll come back.

mathias
Quartz | Level 8

Well, it seem to work with my code as well. Smiley Happy

Even the javascript modifying the img src's on the fly works.

It's a big achievement.

I thought images would disapear after some time but they keep rendering.

However it's very slow.

It looks like each image is being loaded everytime it is shown. (I make them disappear / appear with javascript by modifying img src=)

With a relative or url Link, images take some time to load the first time, but once done, they are stored in the browser cache and it's instantaneous.

I need to understand why this is not happening here.

Quentin
Super User

Glad to hear!

I'm at the boundary of my understanding here (as evidenced by several attempts to try to get it working, and giving up last night only to wake up this morning thinking "it should work!!!", and finally resorting to my old standby of running %STPBEGIN and then trying to do whatever it does).

I don't know much about javasript/caching.  Hoping to learn more as time goes on.... : )

--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.
mathias
Quartz | Level 8

Many thanks for your help Quentin !

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
  • 15 replies
  • 5677 views
  • 4 likes
  • 2 in conversation