BookmarkSubscribeRSS Feed
BenBrady
Obsidian | Level 7

I have created a bar chart using proc gchart with the relevant code below that produces this. However, I am wishing to add an image from a local drive that is a jpeg called 'log.jpeg' as a background to the chart and was wandering how to go about doing this. Cheers.

 

 

data methods_15;
input Method $ Percent ;
datalines;
One 69.64
Two 79.73
Three 80.59
Four 80.83
Five 87.55

run;




/* Set the graphics environment */                                                                                                      
goptions reset=all  cback=aliceblue htext=10pt htitle=12pt ctext=goldenrod noborder ;     


                                                                                                                                        
/* Create the Annotate data set*/                                                                                                       
data anno;                                                                                                                              
   length function color $8 style $12;                                                                                                  
   retain function 'label' when 'a' size 1.25 position '2'                                                                              
          color 'black' xsys '2' ysys '2' style 'Albany AMT';                                                                           
   set methods_15;                                                                                                                   
    where Method in ( 'One','Two','Three','Four','Five');                                                                              
   if Method in ('One','Two','Three','Four','Five') then color='blue';                                                                                         
                                                                                                                  
   midpoint=Method;                                                                                                                       
   y=Percent;
text=put(Percent,4.1) ;
  axis1 label=(f='Albany AMT/bold' 'Method')
order=('One' 'Two' 'Three' 'Four' 'Five');
axis2 label=(f='Albany AMT/bold' '%');
run;                                                                                                                                    
                                                                                                                                        
/* Add a title to the graph */                                                                                                          
title 'Correct Classification';  

/*Colours for the bars - Note how it does it in alphabetical order */
Pattern1 color=lilg;
pattern2 color=lightorange;
pattern3 color=lightblue;
pattern4 color=lightred;
pattern5 color=lightblack;
                                                                                                                                        
/* Produce the bar chart */                                                                                                             
proc gchart data=methods_15;   
where Method in ( 'One','Two','Three','Four','Five');  
                                                                      
   vbar Method / sumvar=Percent annotate=anno                                                                                              
               patternid=midpoint width=10 maxis=axis1 raxis=axis2 autoref noframe cautoref=bippk;   

run;                                                                                                                                    
quit;                                                                                                                                   
             

 

 

4 REPLIES 4
Reeza
Super User

See the methods here with fully worked examples

http://robslink.com/SAS/democd43/turkey_price_info.htm

 

Note, that if you have the option you should consider using SGPLOT instead. It creates better quality graphics with more options and easier to use. 

ballardw
Super User

GCHART is designed to work with device graphics, orginally pens placed into holders on a plotter, and the newer SGPLOT does much more than gchart.

 

With that said, the options IFRAME= in the VBAR options, or IBACK = in a GOPTIONs statement, will include an image file by pointing to the location. Note: IFRAME is not supported by Java.

DanH_sas
SAS Super FREQ

For completeness, I'll mention that the way to do this in SGPLOT is to use SG annotation. See pages 9-13 of my paper below to see what you can do with images. For the wall (iFRAME) case, you will need to turn the wall off (NOWALL option) to see the image through the wall area.

 

Hope this helps!

Dan

 

https://support.sas.com/resources/papers/proceedings11/277-2011.pdf

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1168 views
  • 0 likes
  • 5 in conversation