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

Hi there,

I want to insert multiple graph file into a single HTML file.

I am using GTL(PROC Template and SGRENDER procedure) to generate graphs to generate graph for several categories(page break). I get output in HTML but I also get SGRENDER1.png,.... SGRENDERn.png.

But how do I get a single HTML file where the image files(png) embedded into a single file.

Can we do this with PROC GREPLAY or Is there any other way?

Thanks in Advance.

Surendar.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

With SAS9.4 you also have the possibility to have the images inline in the HTML source, so there is just the HTML output. You will use the HTML5 destination for this, see sample below.

ods graphics / outputfmt=svg;

ods html5 file="c:\temp\sample_svg.html" options(svg_mode='inline');
proc sgplot data=sashelp.cars;
  vbar origin;
run;

proc sgplot data=sashelp.cars;
  vbar type;
run;

ods html5 close;

ods graphics / outputfmt=png;

ods html5 file="c:\temp\sample_png.html" options(bitmap_mode='inline');
proc sgplot data=sashelp.cars;
  vbar origin;
run;

proc sgplot data=sashelp.cars;
  vbar type;
run;

ods html5 close;

View solution in original post

11 REPLIES 11
BrunoMueller
SAS Super FREQ

Since you already use GTL and Proc SGRENDER you can combine your individual graphs into one statgraph defintion using nested layouts. Please be aware that all the data for the individual graphs must come from the same data set. See a sample below using SASHELP.CARS. Maybe SGPANEL might be another option. If you show us what it should look like will help.

proc template;
 
define statgraph lattice_layout_nested;
    begingraph / designwidth=1200  designheight=800;
     
layout lattice / rows=2  rowgutter=5 rowweights=(0.3 0.7);
        layout lattice / columns=2 columngutter=5 columnweights=(0.7 0.3);
          layout overlay /
           
walldisplay=(outline)
           
xaxisopts=(display=(tickvalues ticks ))
           
yaxisopts=(display=(tickvalues ticks ))
          ;
            entry "Graph 1" / valign=top location=outside;
            barchart x=type / group=type name='bar3' stat=freq;
          endlayout;
         
layout overlay /
           
walldisplay=(outline)
           
xaxisopts=(display=(tickvalues ticks ))
           
yaxisopts=(display=(tickvalues ticks ))
            ;
            entry "Graph 2" / valign=top location=outside;
            barchart x=ORIGIN / group=origin name='bar' stat=freq;
          endlayout;
       
endlayout;
       
layout overlay /
         
walldisplay=(outline)
         
xaxisopts=(
           
display=(tickvalues ticks )
            discreteopts=(tickvaluefitpolicy=rotate)
          )
         
yaxisopts=(display=(tickvalues ticks ))
        ;
          entry "Graph 3" / valign=top location=outside;
          barchart x=MAKE /  name='bar2' stat=freq ;
        endlayout;
     
endlayout;
   
endgraph;
 
end;
run;

ods graphics / reset;

proc sgrender data=sashelp.cars template=lattice_layout_nested;
run;
Jay54
Meteorite | Level 14

Close the ODS LISTING destination.

ChrisHemedinger
Community Manager

You could use ODS LAYOUT to combine multiple graphs in a grid-style layout within a single HTML file.  See the ODS LAYOUT documentation for more examples; I have a simple example within this post:

Implement BY processing for your entire SAS program - The SAS Dummy

It's also a good idea to name your graph files when possible, using the IMAGENAME option on the ODS GRAPHICS statement.  Use RESET=INDEX to provide consistent numbering when you rerun your program to update the results.

More here: SAS(R) 9.4 Output Delivery System: User's Guide, Second Edition

Chris

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Quentin
Super User

Hi,

Assume this is the same question from:

  https://communities.sas.com/thread/52976

Was my last suggestion there not what you were looking for?  Do you literally want to embed an image in the html file using html5 (as in my first response)?  Still confused...

--Q.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Joe Madden & Joseph Henry present Putting Power into the Hands of the Programmer with SAS Viya Workbench on Wednesday Nov 6.
Register now at https://www.basug.org/events.
suraestar
Calcite | Level 5

Hi.

Yes I want all the image files to be embeded into a single Html file like how we generate for RTF or PDF..

suraestar
Calcite | Level 5

Dear All,

Thanks For quick responses!!!

I forgot to add one point that my template will be executed only once but I would Call the SGRENDER Procedure multiple times.

Proc template;

define statgraph pag_brk;

.......

quit;

DO i=1 for each  categories;

data temp;

set source;

if variable=%scan(category,&i,/);

run;

proc sgrender data=temp template=pag_brk;

run;

end do;

I get output as below, One single html file which refers Two png files.Incase if we delete this file then you cannot view these images in html file(since unlike rtf or pdf the html refers the path of the image file)

So I would like to have a Single Html file where these two files embeded in to it.

Capture.PNG

Many Thanks....

Surendar.

suraestar
Calcite | Level 5

Hi All.

I have one more help regarding the template creation. could you please help.

https://communities.sas.com/message/198553#198553

BrunoMueller
SAS Super FREQ

With SAS9.4 you also have the possibility to have the images inline in the HTML source, so there is just the HTML output. You will use the HTML5 destination for this, see sample below.

ods graphics / outputfmt=svg;

ods html5 file="c:\temp\sample_svg.html" options(svg_mode='inline');
proc sgplot data=sashelp.cars;
  vbar origin;
run;

proc sgplot data=sashelp.cars;
  vbar type;
run;

ods html5 close;

ods graphics / outputfmt=png;

ods html5 file="c:\temp\sample_png.html" options(bitmap_mode='inline');
proc sgplot data=sashelp.cars;
  vbar origin;
run;

proc sgplot data=sashelp.cars;
  vbar type;
run;

ods html5 close;
suraestar
Calcite | Level 5

Hi,

Yeah, I explored SAS 9.4 features that it has HTML5 destination which fulfil my need. Since I use 9.3v Is there any other possible way?

Thanks..

BrunoMueller
SAS Super FREQ

I am not aware of anything in SAS9.3

how about creating a PDF instead

How is the HTML made available to the user?

suraestar
Calcite | Level 5

I need HTML output(i have already generated RTF and PDF for this output)

Thats fine.

Thanks for your help..

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
  • 11 replies
  • 4166 views
  • 3 likes
  • 5 in conversation