How can I control the width of the legend when I use KEYLEGEND? It is truncating my title when it appears that it has ample room based on the width of the plot:
keylegend / title = "Lab Test" down = 1 linelength = 10% ;
I produced the snippet of the figure using SGPLOT setting the HEIGHT and WIDTH options to the ODS GRAPHICS to 4.5in and 9.0in, respectively.
Thank you,
Kevin
Can you please provide the SGPLOT statements you are using? This appears to work in the following example:
ods graphics/reset;
proc sgplot data=sashelp.cars;
where type in ('SUV' 'Sedan' 'Wagon' 'Truck');
reg x=weight y=mpg_highway / group=type;
keylegend / title = "Very Long Legend Title"
down = 1
linelength = 10%
;
run;
Rick,
Thank you for your suggestion. I have experimented more. I used a custom style. I found that changing the following:
"GraphLabelFont" = ( "&font."
, 10pt
)
to variations such as:
"GraphLabelFont" = ( "&font."
, 10pt
, bold
)
eliminated the issue:
The same was true for changing just the font size to 11pt, for instance. Surprisingly, decrease the font size to 9pt did not eliminate the issue. Changing the fontface to "Courier New" with 10pt also eliminated the issue. Using your code, modified to "match" my original code, I was able to replicate the issue. Omitting the STYLE = forma option to the ODS RTF statement, the issue resolved. The offending code that produces:
is:
ods path ( prepend )
work.templat
( write )
;
proc template ;
define style
styles.forma2 / store = work.templat
;
parent = styles.pearl ;
class GraphFonts
/ "GraphLabelFont" = ( "Times New Roman"
, 10pt
, bold
)
"GraphValueFont" = ( "Times New Roman"
, 10pt
)
;
end ;
run ;
ods path ( remove )
work.templat
;
ods path ( prepend )
work.templat
( read )
;
ods graphics/reset;
ods graphics on
/ width = 9.0in
height = 4.5in
noborder
;
ods rtf
file = "&outpath.\&outfile.9b.rtf"
nogtitle
nogfootnote
style = forma2
;
ods listing close ;
ods results ;
proc sgplot data = sashelp.cars ;
where type in ('SUV' 'Sedan' 'Wagon' 'Truck');
reg x=weight y=mpg_highway / group=type ;
keylegend / title = "Lab Title"
down = 1
linelength = 10%
;
format weight 8.0 ;
run;
ods rtf close ;
ods listing ;
ods noresults ;
Thank you,
Kevin
Thanks for the reproducible example. @DanH_sas might find your example interesting.
Rick,
I understand that you were able to reproduce it? Perhaps this is an issue with the TEMPLATE? If so, I am looking forward to Dan's reaction, but that would seem to me that I also should open a tech support ticket? (I will have to create an account for my new employer.)
Thank you,
Kevin
No, I did not try to reproduce it. I don't have much experience with styles.
Hey Kevin,
Using your test program, I was not able to reproduce the problem using the latest release. What version of SAS are you running, and on what host?
Thanks!
Dan
Thanks for the reply. I have a ticket with Lelia McConnell of SAS Tech Support. I was able to replicate it in RTF, but the PDF was fine. I generated them in the same program. She has the full log and the two output. She requested the _AUTOMATIC_ macro variables and I also provided her the SOURCE from Template.
Current version: 9.04.01M5P091317
<SNIPPED>
Operating System: WX64_WKS.
I will update this thread if (when) I get an answer.
Kind regards,
Kevin
Hey Kevin,
In your RTF run, try adding this to your program and see if you get the correct output.
ods graphics / imagefmt=png;
It could be an EMF output issue. If so, using PNG should fix it.
Thanks!
Dan
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.