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;
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
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.