BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there a way to include page numbers on graphs created by proc gchart and ouput to the PDF destination? I'm using SAS 9.2.

Thanks,

Jeff
3 REPLIES 3
ArtC
Rhodochrosite | Level 12
How automatic do the page numbers need to be? Do they need to be on the graph it self or just on the page that contains the graph (will the graph be imbedded in a report or table or on its own)?

SAS/GRAPH is not going to 'know' the page when the graph is rendered. So to place the number on the graph you will have to know and then pass the number into the graph. It might be easier to insert the graph into a table, even a layout page, which will receive its number automatically.
deleted_user
Not applicable
I should have been more specific. The program creates a series of graphs with BY group processing. I thought I remembered reading somewhere that with SAS/Graph 9.2 it was possible to use the {thispage} function. I was hoping there was an easy way to do it that I was just missing. I seems like a pretty common thing to want to do.

I'm going to try to create a macro variable that contains the page number for each BY value and output that in a footnote.

Thanks,

Jeff
Cynthia_sas
SAS Super FREQ
Hi:
I believe that in-line formatting (such as {thispage}) works for RTF in SAS 9.2, but not for PDF (yet). The reason that using in-line formatting works at all in titles for RTF is that there is a NOGTITLE and NOGFOOTNOTE option for RTF destination, that tells SAS/GRAPH to let ODS control the title and footnote. PDF does not currently have those options (although it is planned for SAS 9.3). You can find the description of the GTITLE option for RTF here:
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/a002233360.htm#a003137604

(Of course, there are no page numbers in HTML output, so {thispage} would not ever work in ODS HTML for that reason. But other in-line formatting will work in HTML and NOGTITLE will work for HTML, as well.)

So, you can't use {thispage} with ODS PDF in SAS 9.2 -- however a simple NUMBER system option will work with SAS/GRAPH in SAS 9.2 for ODS PDF, as shown in the program below. When I run the code, I get 3 pages of output, one for each BY group from the GCHART and the page number is in the upper right hand corner of each page.

cynthia
[pre]
ods listing close;
options nodate number pageno=1;

proc sort data=sashelp.shoes out=shoes;
where region in ('Asia', 'Pacific', 'Canada');
by region product;
run;

ods pdf file='c:\temp\sasgraf_page_option.pdf';

proc gchart data=shoes;
by region;
title 'Use NUMBER System Option';
vbar product / sumvar=sales;
run;
quit;
ods pdf close;
title; footnote;

** Compare RTF output;
ods listing close;
options nodate nonumber;

ods rtf file='c:\temp\sasgraf_nogtitle_option.rtf' nogtitle;

ods escapechar='^';
proc gchart data=shoes;
by region;
title j=c 'RTF with NOGTITLE' j=r 'Page ^{thispage}';
vbar product / sumvar=sales;
run;
quit;
ods rtf close;
[/pre]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 2435 views
  • 0 likes
  • 3 in conversation