I am having a recurring issue where labels are frequently truncating in legends in both SGPANEL and SGPLOT. There is plenty of room for the labels so I have no idea why this is happening.
Example code below:
options orientation=landscape;
ods escapechar='~';
ods graphics on /width = 9in height =4in noborder;
ods rtf file="&output.\&Tfloutput..rtf" style=rtfdef startpage=yes nogfootnote nogtitle;
proc sgpanel data=final;
by paramn param;
panelby mct / columns=1 rows=4;
hbar trt01pn / response=rowpercent group=respn name="plot" ;
colaxis label='Percent of Total Frequency';
rowaxis label=' ' type=discrete reverse;
keylegend "plot"/ title="Status";
format trt01pn trt. respn resp.;
run;
ods rtf close;Screen shot of truncated legend label below. Even if I use across to do one label per line in the legend it still truncates. Any suggestions of a fix?
Do you get the same behavior if you add OUTPUTFMT=PNG to the ODS GRAPHICS statement in your program?
I had this same problem, it happened when the version of SAS Studio in SAS Viya changed. The default fonts changed, the default style changed and I saw the exact same truncation of labels that you are seeing. The solution is quoted below, verbatim, that my local support people received from SAS.
This is a known issue with newer versions of SAS Studio due to a change that R&D made. By default, newer versions of SAS Studio use the following new ODS style:
Light2025
I can easily recreate this issue here. The issue is due to the default style that SAS uses when using newer versions of SAS Viya.
To see if this circumvents the issue, please do the following.
When in a SAS Studio/SAS Viya session, click the "login" icon in the upper-right hand corner of the SAS Studio window. This is the icon just to the right of the question mark ("?") icon.
Then, choose:
Settings
Under:
SAS Programs
Select:
Results
On the right-hand side, enable the following option:
Specify an HTML output style
And for the style, choose a style such as:
HTMLBlue
Or:
HTMLEncore
Then click:
Close
For the record, the font issue described by @PaigeMiller has been addressed. The newer styles such as Light2025 should no longer have the truncation issue.
@DanH_sas wrote:
For the record, the font issue described by @PaigeMiller has been addressed. The newer styles such as Light2025 should no longer have the truncation issue.
Good to know. Thanks, @DanH_sas !
Can you show more of the graph area containing the legend to give a little more context?
Sure. Here you go.
Are you using SAS Viya 4? If so, what version?
No not SAS Viya. Just standard DMS 9.4
Do you get the same behavior if you add OUTPUTFMT=PNG to the ODS GRAPHICS statement in your program?
No!! This fixes it! This has been driving me mad for ages so many thanks!
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.