Hi,
I'm using SGRENDER to output a box plot to RTF, and consumers want easy cut-paste to PowerPoint. (Don't have 9.4 yet, so can't try ODS to powerpoint). I'm using imagefmt=EMF.
I have TITLE statements for my titles.
Titles are going to the header of the RTF document, so cut-paste is a hassle for users. I thought "no problem, I'll just set GTITLE on the ODS statement". But while that would do what I want for SGPLOT, it doesn't effect SGRENDER.
Looks like if I want the titles in the image with SGRENDER, I need to switch from using title statements to using ENTRYTITLE in the GTL, is that right?
My other thought to (save all of my title statements), was to turn on BODYTITLE. So the title would not be part of the image, but since it's in the body of the rtf, it's easier to cut-paste. But at least with Office 2003, while the RTF document looks good in word (titles centered above the image), when I paste it into powerpoint the title text goes into a text box separate from the image, and is left aligned.
So my questions:
1. Using SGRENDER, is there a way to get titles defined on a TITLE statement to be printed in the image?
2. If not, any other suggestions for managing title text when generating RTF that will eventually end up in PowerPoint?
Thanks,
--Q.
proc template; define statgraph MyBoxPlot; begingraph; layout overlay ; boxplot x=Region y=Sales ; endlayout; endgraph; end; run; ods graphics/reset=all; ods _all_ close; ods rtf file="d:\junk\me.rtf" gtitle ; title1 "This is a title"; title2 "I am a subtitle"; proc sgrender data=sashelp.shoes template="MyBoxPlot" ; run; proc sgplot data=sashelp.shoes; vbox sales/group=region; run; title1; ods _all_ close; ods listing;
For question #1, I can definitely tell you that you cannot use TITLE/FOOTNOTE statements with GTL/SGRENDER. However, TITLE/FOOTNOTE statements will work with SG procedure output (SGPLOT/SGPANEL/SGSCATTER). The underlying rendering system is the same, so if the plot you're creating does not require a GTL-only option, I would use the SG procedures to solve both of your problems. However, if you require GTL, you can use ENTRYTITLE/ENTRYFOONOTE statements in the template to define your text. I would also make the text dynamic so that you can pass it into SGRENDER. Here is an example using your code:
proc template;
define statgraph MyBoxPlot;
dynamic TITLE1 TITLE2;
begingraph;
entrytitle TITLE1;
entrytitle TITLE2;
layout overlay ;
boxplot x=Region y=Sales ;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.shoes template="MyBoxPlot" ;
dynamic TITLE1="This is a title";
dynamic TITLE2="I am a subtitle";
run;
Hope this helps!
Dan
Thanks Dan,
Building off of your suggestion to make the title text dynamic, maybe I'll play with a macro function solution that would read the title text from sashelp.vtitle, and generate the dynamic statement for me.
so end up with:
proc sgrender data=sashelp.shoes template="MyBoxPlot";
%MakeDynamicTitles() /*read titles from sashelp.vtitle and generate one DYNAMIC statement for each*/
run;
Could be useful when you have titles defined for tables, and want them to be honored for plots.
But actually, since I'm already passing the titles in a macro call, I can just do:
proc sgrender data=sashelp.shoes template="MyBoxPlot";
dynamic TITLE1="&title1";
run;
Thanks,
--Q.
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!
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.