BookmarkSubscribeRSS Feed
craig159753
Quartz | Level 8

Hi, 

 

So I am producing a figure using GTL within SAS EG on SAS 9.4, now the code works perfectly, and if i produce an RTF it looks perfect. Now when I produce the PDF file for some reason the graphic output shrinks. 

 

 

options leftmargin = 1.54cm
rightmargin = 1.54cm
bottommargin = 2.13cm
topmargin = 1.54cm;


proc template;
define statgraph lineplot_template;
begingraph / border = FALSE
designwidth = 800
designheight = 300;
layout overlay /
xaxisopts = (name = "x_axis"
label = "X Axis Label"
labelattrs = (color = BLACK family = "COURIER NEW" size = 10 style = NORMAL weight = NORMAL)
display = (Line Label Ticks TickValues)
offsetmin = 0.005
offsetmax = 0.005
type = linear
linearopts = (tickvaluefitpolicy = NONE
tickvaluelist = (0 12 24 36 48 60 72 84 96 108 120 132 144 156 168 180 192 204)
tickvaluepriority = TRUE))
yaxisopts = (name = "y_axis"
label = "Y Axis Label"
labelattrs = (color = BLACK family = "COURIER NEW" size = 10 style = NORMAL weight = NORMAL)
display = (Line Label Ticks TickValues)
offsetmin = 0.05
offsetmax = 0.05
type = linear
linearopts = (tickvaluefitpolicy = NONE
tickvaluesequence = (start = 0 end = 100 increment = 10)
includeranges = (0-40 55-70)
tickvaluepriority = TRUE));

seriesplot x = weekn y = geomean / name = "LinePlot"
group = acdposta
display = (markers)
xaxis = X
yaxis = Y
lineattrs = (thickness = 1)
markerattrs = (size = 7 symbol = CIRCLE transparency = 0 weight = NORMAL);

scatterplot x = weekn y = geomean / name = "ScatterPlot"
group = acdposta
errorbarcapshape = none
yerrorlower = geolclm
yerrorupper = geouclm;
endlayout;
endgraph;
end;
run;

ods listing close; ods pdf file = "&outname..pdf" nogtitle nogfootnote; ods graphics on / reset = all imagefmt = png; /* This next prodcedure will go between the ODS RTF lines within your program */ proc sgrender data = mydata template = lineplot_template; run; ods graphics off; ods pdf close; ods listing;

 

 

The margins do have an affect on the output, but even when they are set to 0, there is a large white space below the output. Any reason why the PDF seems to compress the output? I have attached an image, for certain obvious reason values need to be nulled. but the large box at the bottom are all the footnotes.


MyFigure.png
7 REPLIES 7
DanH_sas
SAS Super FREQ

On your DESIGNWIDTH and DESIGNHEIGHT values, put a "px" on the end of your values (i.e. 800px, 300px). I think what's happening is that the default unit of "scaled" pixels is being used, which, in PDF, can cause your graph to shrink. It's always best to put the units on the end of dimension values to help prevent issue like this from occurring.

 

Thanks!
Dan

craig159753
Quartz | Level 8

Hi Dan, thanks for your response. However this did not work, I actually do have units present usually. Any other suggestions?

DanH_sas
SAS Super FREQ

 

Hmm... here are a couple of other things to try:

 

1) On your DESIGNWIDTH/DESIGNHEIGHT, specify IN or CM instead of PX. The default DPI for RTF is 200, while it is 150 for PDF. I want to see if there is a DPI scaling issue.

 

2) Instead of specifying DESIGNWIDTH/DESIGNHEIGHT, try using the WIDTH and HEIGHT options on the ODS GRAPHICS statement instead. The DESIGNWIDTH/DESIGNHEIGHT options have a different effect on the graph versus using WIDTH and HEIGHT.

 

Try these two things separately, and let me know if you see any differences.

 

Thanks!
Dan

craig159753
Quartz | Level 8

Hi Dan,

 

1) I changed this to 8in and 3in and it looked the same so i increaed this to 20in and 10in, still the same.

 

2) I previosuly tested this, but no luck. I tired again away and yep still nothing 😕

 

It seems to be as if the body of the output contains a large white space (below the graph but above the foonotes), because if i remove all foonotes the output does get considerably bigger. But like i said this only affects PDF

DanH_sas
SAS Super FREQ

Can you provide a screenshot of your RTF output versus your PDF output?

craig159753
Quartz | Level 8

Hi Dan, 

 

sorry for the late reply, I have attached my RTF output

 

 


MyRTFFigure.png
Jay54
Meteorite | Level 14

I ran your code with SASHELP.CLASS using x=weight and y=age and could not reproduce the problem you are seeing.  Both PDF and RTF of the right size.  I suggest you can remove IMAGEFMT=PNG from the code to get scalable graphs.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 2484 views
  • 1 like
  • 3 in conversation