Data visualization with SAS programming

Page Numbers on PDF

Reply
N/A
Posts: 0

Page Numbers on PDF

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
Valued Guide
Posts: 632

Re: Page Numbers on PDF

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.
N/A
Posts: 0

Re: Page Numbers on PDF

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
SAS Super FREQ
Posts: 8,716

Re: Page Numbers on PDF

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]
Ask a Question
Discussion stats
  • 3 replies
  • 451 views
  • 0 likes
  • 3 in conversation