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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.