Data visualization with SAS programming

Title and Footnote outside and inside a graph

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

Title and Footnote outside and inside a graph

[ Edited ]

Dear all,

 

I'm working with SAS EG (7.1 HF1 (7.100.0.2002) (64-bit)).

 

I'm trying to include both inner an outer titles and footnotes to a graph that I'm saving into a pdf document. I have read about the gtitle/nogtitle and gfootnote/nogfootnote options. They are not working for me (don't make any difference in the output, both title and footnote appear outside the graph) with the code that I'm attaching.

 

However, even if these statements were working, I think that wouldn't solve my problem. If I understood correctly, these statements make the location of the title/footnote exclusive to the inner graph area OR the outer graph area, but you couldn't make both.

 

Is there a way to do this?

 

In the code I'm showing what I would like to achieve, although this is obviously no the way to do it...

 

ods pdf file="test_graph.pdf";

title 'Title outside the graph (title of the document)';
footnote 'Footnote ouside the graph (footnote of the document)';

proc sgplot data=sashelp.cars;
	title 'Title inside the graph (title of the graph)';
	footnote 'Footnote inside the graph (footnote of the graph)';
	scatter x=Horsepower Y=Invoice;
run;

title;
footnote;
ods pdf close;

Thanks in advance for your help!!


Accepted Solutions
Solution
‎05-25-2017 04:10 AM
SAS Super FREQ
Posts: 916

Re: Title and Footnote outside and inside a graph

Glad it worked for you. Here is an example with both titles and footnotes on the inside:

 

ods pdf file="temp.pdf" nogtitle nogfootnote;

data inside;
retain function "text" drawspace "graphpercent" width 100 x1 50;
length anchor $ 6 textstyleelement $ 17 label $ 18;
input y1 anchor $ textstyleelement $ label $ 29-46;
cards;
99 top    GraphTitleText    My Inside Title
1  bottom GraphFootnoteText My Inside Footnote
;
run;

title "My Outside Title";
footnote "My Outside Footnote";
proc sgplot data=sashelp.class pad=(top=5% bottom=5%) sganno=inside;
vbar age;
run;
ods pdf close;

As for your other question, this will work for the SGPLOT, SGPANEL, and SGSCATTER procedures. The SGRENDER procedure also supports annotation; but, since you would be using GTL in that case, you could just use ENTRYTITLE and ENTRYFOOTNOTE to do what you needed.

 

Thanks!
Dan

View solution in original post


All Replies
Super User
Posts: 10,820

Re: Title and Footnote outside and inside a graph

Please see this thread for a similar issue why when using EG the gtitle behavior may not quite be as expected

https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/Title-inside-the-graph-and-not-above-with-...

 

@DanH_sas may come up with additional bits but I suspect to get "titles" both inside and outside may require using either ODS Text (before the graph) of annotate (inside a graph) to provide additional text.

 

SAS Super FREQ
Posts: 916

Re: Title and Footnote outside and inside a graph

Fir of all, here is how you control title/footnote placement in EG. By default, EG sets NOGTITLE and NOGFOOTNOTE for the graph output, but do the steps below to change it.

 

1. Go to Tools->Options

2. In the left pane, under "Results", click on the "Graph" item

3. In the right pane, clicl on the two check boxes to include titles and footnotes in the graph

 

Both techniques mentioned by @ballardw can work, but the one you choose will depend on where you want the OUTSIDE titles and footnotes to be placed in the PDF page. If you want the outside titles and footnotes at the top and bottom of the page (regardless of graph size), then you should use TITLE and FOOTNOTE statements with your ouside titles along with NOGTITLE/NOGFOOTNOTE to have them processed outside of the graph. Your inside title, you would use annotation with padding. Here is a simple exampleSmiley SadFor EG output, drop the ODS PDF statements and just request PDF output)

 

ods pdf file="temp.pdf" nogtitle nogfootnote;

data inside;
function="text";
label="My Inside Title";
anchor="top";
textsize="12";
textweight="bold";
drawspace="graphpercent";
y1=99;
x1=50;
width=100;
run;

title "My Outside Title";
footnote "My Outside Footnote";
proc sgplot data=sashelp.class pad=(top=5%) sganno=inside;
vbar age;
run;
ods pdf close;

Hope this helps!

Dan

 

 

Contributor
Posts: 31

Re: Title and Footnote outside and inside a graph

[ Edited ]

Hi @DanH_sas,

 

Thank you for your quick response. It totally solves my title problem. What about the inner footer? Is it possible to have an outer and  an inner one? And what if I would like to use a different plot procedure? Will the sganno option still be available?

 

Thanks again in advance!! Smiley Happy

 

Regards,

 

Lucía

Solution
‎05-25-2017 04:10 AM
SAS Super FREQ
Posts: 916

Re: Title and Footnote outside and inside a graph

Glad it worked for you. Here is an example with both titles and footnotes on the inside:

 

ods pdf file="temp.pdf" nogtitle nogfootnote;

data inside;
retain function "text" drawspace "graphpercent" width 100 x1 50;
length anchor $ 6 textstyleelement $ 17 label $ 18;
input y1 anchor $ textstyleelement $ label $ 29-46;
cards;
99 top    GraphTitleText    My Inside Title
1  bottom GraphFootnoteText My Inside Footnote
;
run;

title "My Outside Title";
footnote "My Outside Footnote";
proc sgplot data=sashelp.class pad=(top=5% bottom=5%) sganno=inside;
vbar age;
run;
ods pdf close;

As for your other question, this will work for the SGPLOT, SGPANEL, and SGSCATTER procedures. The SGRENDER procedure also supports annotation; but, since you would be using GTL in that case, you could just use ENTRYTITLE and ENTRYFOOTNOTE to do what you needed.

 

Thanks!
Dan

Contributor
Posts: 31

Re: Title and Footnote outside and inside a graph

Thanks for your detailed explanation, @DanH_sas!! Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 270 views
  • 0 likes
  • 3 in conversation