Data visualization with SAS programming

Multiple Graph into a Single HTML using GTL.

Accepted Solution Solved
Reply
Contributor
Posts: 46
Accepted Solution

Multiple Graph into a Single HTML using GTL.

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.


Accepted Solutions
Solution
‎02-27-2014 03:20 AM
SAS Super FREQ
Posts: 620

Re: Multiple Graph into a Single HTML using GTL.

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


All Replies
SAS Super FREQ
Posts: 620

Re: Multiple Graph into a Single HTML using GTL.

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;
SAS Super FREQ
Posts: 1,044

Re: Multiple Graph into a Single HTML using GTL.

Close the ODS LISTING destination.

Community Manager
Posts: 2,606

Re: Multiple Graph into a Single HTML using GTL.

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

Trusted Advisor
Posts: 1,151

Re: Multiple Graph into a Single HTML using GTL.

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.

Contributor
Posts: 46

Re: Multiple Graph into a Single HTML using GTL.

Hi.

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

Contributor
Posts: 46

Re: Multiple Graph into a Single HTML using GTL.

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.

Contributor
Posts: 46

Re: Multiple Graph into a Single HTML using GTL.

Hi All.

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

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

Solution
‎02-27-2014 03:20 AM
SAS Super FREQ
Posts: 620

Re: Multiple Graph into a Single HTML using GTL.

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;
Contributor
Posts: 46

Re: Multiple Graph into a Single HTML using GTL.

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

SAS Super FREQ
Posts: 620

Re: Multiple Graph into a Single HTML using GTL.

I am not aware of anything in SAS9.3

how about creating a PDF instead

How is the HTML made available to the user?

Contributor
Posts: 46

Re: Multiple Graph into a Single HTML using GTL.

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

Thats fine.

Thanks for your help..

Post a Question
Discussion Stats
  • 11 replies
  • 1474 views
  • 3 likes
  • 5 in conversation