BookmarkSubscribeRSS Feed
fastb
Fluorite | Level 6

Hi,

 

I am generating a series of plots using an SGPLOT macro and I have an image that I want to use for the background of all of the plots.

 

When I was making the plots one at a time without the macro the annotate function worked fine to add the image to the plot background.

However, that does not work with the macro.  I suspect that I need to add an SG macro to the code to accomplish this.

Can anyone provide me with the code that would accomplish that?

 

Thanks!


%MACRO SGPLOT; %DO i=1 %TO &total;
 
ods listing style = map_symbols  gpath = '\\C:Macro Plots\Output Files' IMAGE_DPI=1200;
ODS GRAPHICS ON / imagename = 'NA Test Map' IMAGEFMT=png IMAGEMAP=on BORDER=off; OPTIONS NOBYLINE;

data annoimage; length function $10.; function = 'image'; height = 90; width = 100; drawspace = 'wallpercent';
image = '\\C:Analysis Files\Plot Background.jpg';
layer = 'back'; run;

PROC SGPLOT DATA=macrovar NOAUTOLEGEND NOCYCLEATTRS sganno =annoImage;
WHERE Site_Code="&&Site_Code&i";
TITLE;
YAXIS grid gridattrs = (color = black) display = (noline nolabel noticks novalues) values=(0 to 100 by 5);
XAXIS grid gridattrs = (color = black) display =(noline nolabel noticks novalues) values=(0 to 100 by 5);
SCATTER x = US_X y = US_Y/
 
ODS GRAPHICS OFF; ODS _ALL_ CLOSE; ODS LISTING CLOSE; %END; %MEND SGPLOT; %SGPLOT;
2 REPLIES 2
DanH_sas
SAS Super FREQ

The slashes appear to be in the wrong place.

image = '\\C:Analysis Files\Plot Background.jpg';

should be

image = 'C:\\Analysis Files\\Plot Background.jpg';

Hope this helps!

Dan

GraphGuy
Meteorite | Level 14

Were there any error messages in the SAS log?

That should probably point you in the right direction!

 

You might need to turn on more robust messages in the log to help get more info. 

If I'm remembering correctly, something like ...

 

options source mprint;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 378 views
  • 1 like
  • 3 in conversation