- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Close the ODS LISTING destination.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
Yes I want all the image files to be embeded into a single Html file like how we generate for RTF or PDF..
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Many Thanks....
Surendar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All.
I have one more help regarding the template creation. could you please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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..
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am not aware of anything in SAS9.3
how about creating a PDF instead
How is the HTML made available to the user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need HTML output(i have already generated RTF and PDF for this output)
Thats fine.
Thanks for your help..