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;

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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 ....

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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;
BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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!)

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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;

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
mathias
Quartz | Level 8

Many thanks for your help Quentin !

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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