BookmarkSubscribeRSS Feed
dagremu
Obsidian | Level 7

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;

PNG vs PDF.jpg

 

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.

5 REPLIES 5
blueskyxyz
Lapis Lazuli | Level 10
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

JeffMeyers
Barite | Level 11
I would try setting the PAPERSIZE option I think that's the one) to about match your image to see if that helps. Something like OPTIONS PAPERSIZE=(5in,6in); before the ODS PDF statement.
PDF isn't really designed for what you're asking though, it'd be like trying to do the same in ods rtf. It's document and not an image.

https://documentation.sas.com/?cdcId=vdmmlcdc&cdcVersion=8.1&docsetId=uprint&docsetTarget=n1ieb4hg6f...
blueskyxyz
Lapis Lazuli | Level 10
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;
blueskyxyz
Lapis Lazuli | Level 10

save as rtf instead of pdf, then you can paste the figure in other files.

Bill_in_Toronto
Obsidian | Level 7

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1563 views
  • 1 like
  • 4 in conversation