When I create a PDF image in SAS, a blank margin area is created around the image that I don't want. Here's an example where I plot the same image twice, first as a PNG, and then as a PDF. Note that the PDF has extra white space outside of the border while the PNG does not. How do I get rid of that extra white space in the PDF?
ods html close;
ods listing;
ods graphics / reset=all outputfmt=png imagename="Test image";
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods graphics / reset=all outputfmt=pdf imagename="Test image";
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods listing close;
Note that I just want a stand-alone image file in PDF format, just like the PNG created above. I don’t need the margins because I’ll be embedding the image file within a manuscript.
ods graphics / reset=all outputfmt=pdf noborder/*<<<added option*/ imagename="Test image";
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods listing close;
please try to add noborder option
ods rtf file="C:\Users\Downloads\test.RTF" style=styles.journal;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods rtf close;
save as rtf instead of pdf, then you can paste the figure in other files.
Here are the ODS graphics options I use most often. The height and width options may address your issue. I find that imagefmt=PDF results in better looking plots, but the resulting file size can be much larger than imagefmt=PNG, depending on the number of data points.
ODS GRAPHICS ON/reset
border = off
antialiasmax=1000000
height = 100pct
width = 100pct
imagefmt=PDF;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.