BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
emera86
Quartz | Level 8

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

5 REPLIES 5
ballardw
Super User

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.

 

DanH_sas
SAS Super FREQ

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 example:(For 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

 

 

emera86
Quartz | Level 8

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!! 🙂

 

Regards,

 

Lucía

DanH_sas
SAS Super FREQ

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

emera86
Quartz | Level 8

Thanks for your detailed explanation, @DanH_sas!! 🙂

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 21878 views
  • 5 likes
  • 3 in conversation