Is there a way to save the webout dataset used by the imagemap macro into a SAS dataset? We want to compile a list of image map names and coordinates to create a lookup table for multiple images on a webpage, and we are not having any luck figuring out how to save just the map name and coordinate data produced by PROC SGPLOT and PROC SGRENDER. I'm really hoping there is a way to avoid having to scrape .htm output to create this dataset if at all possible.
Interesting idea. Could you post a little example of code generating the html output with imagemap you like (e.g. PROC SGPLOT on sashelp.class) and also post the imagemap name and coordinates you would like to have output?
With the example below, I'd like to be able to output the map name and each of that tags attributes in a table. The section of .htm output that I'd like to convert into a dataset is also shown below. So, I'd have one column that would have the name 'carsSample1' repeated in multiple rows and separate columns for the alt, title, and coords associate with each shape.
proc template;
define statgraph pieChart;
dynamic _NEGATIVE_;
dynamic _ticklist_;
begingraph / collation=binary datacolors=(cx004B8D cx439639 cxD9541E cx9F218B cxC3A204) ;
EntryTitle "Sample Pie Chart" /;
layout region ;
piechart category=make response=EngineSize /
datalabellocation=outside ;
endlayout;
endgraph;
end;
define style pieChartStyle;
parent=styles.listing;
style graphfonts from graphfonts /
'GraphDataFont' = ("Verdana, <MTsans-serif>",7pt)
'GraphUnicodeFont' = ("<MTsans-serif-unicode>",9pt)
'GraphValueFont' = ("Verdana, <MTsans-serif>",9pt)
'GraphLabel2Font' = ("Verdana, <MTsans-serif>",10pt)
'GraphLabelFont' = ("Verdana, <MTsans-serif>",10pt)
'GraphFootnoteFont' = ("Verdana, <MTsans-serif>",10pt)
'GraphTitleFont' = ("Verdana, <MTsans-serif>",11pt)
'GraphTitle1Font' = ("Verdana, <MTsans-serif>",14pt)
'GraphAnnoFont' = ("Verdana, <MTsans-serif>",10pt);
end;
run;
ods listing close;
ods graphics / imagemap=on imageName="carsSample" antialiasmax=10000 imagefmt=png width=300px height=300px ;
/* Set path for output */
ods html path=' ' file='carsSample.htm' style=pieChartStyle;
proc sgrender data=sashelp.cars template=pieChart ;
run;
ods graphics off;
ods html close;
ods listing;
<map name="carsSample1"> <Area shape="poly" alt="Make=Other Engine Size (L)= 830.6" title="Make=Other Engine Size (L)= 830.6" coords="84,107,71,130,66,156,69,182,80,206,99,226,122,238,148,243,174,239,198,227,217,209,229,185,233,159,150,159,84,107,"/> <Area shape="poly" alt="Make=Toyota Engine Size (L)= 75.1" title="Make=Toyota Engine Size (L)= 75.1" coords="106,88,84,107,150,159,106,88,"/> <Area shape="poly" alt="Make=Nissan Engine Size (L)= 57.9" title="Make=Nissan Engine Size (L)= 57.9" coords="126,79,106,88,150,159,126,79,"/> <Area shape="poly" alt="Make=Mercedes-Benz Engine Size (L)= 101.5" title="Make=Mercedes-Benz Engine Size (L)= 101.5" coords="164,77,145,75,126,79,150,159,164,77,"/> <Area shape="poly" alt="Make=Ford Engine Size (L)= 81.7" title="Make=Ford Engine Size (L)= 81.7" coords="194,88,164,77,150,159,194,88,"/> <Area shape="poly" alt="Make=Chevrolet Engine Size (L)= 100.8" title="Make=Chevrolet Engine Size (L)= 100.8" coords="221,115,209,100,194,88,150,159,221,115,"/> <Area shape="poly" alt="Make=BMW Engine Size (L)= 62.5" title="Make=BMW Engine Size (L)= 62.5" coords="230,137,221,115,150,159,230,137,"/> <Area shape="poly" alt="Make=Audi Engine Size (L)= 58.1" title="Make=Audi Engine Size (L)= 58.1" coords="233,159,230,137,150,159,233,159,"/> </map>
Thanks for adding example. I'm going to move this to the "SAS/GRAPH and ODS Graphics" community. I think it should attract the right eyeballs there.
I looked at the docs a bit, but can't see a way to get the imagemap as data. Parsing the html might be the only way. Unless one of the ODS graphics wizards has an idea. @Jay54 @DanH_sas @Vince_SAS
I think that the only way to do this is to write DATA step code to post-process the file to retrieve the information that you need.
Vince DelGobbo
SAS R&D
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.