BookmarkSubscribeRSS Feed
COMPAREMISSING
Calcite | Level 5

I need to create a pdf and a rtf file with two kind of numbering:

the page number respect to the entire document and

the page number respect to the table (for the tables that last more than 1 page).

 

Is that possible? how to deal with this in the report code?

 

Thanks a lot

 

Barbara Pomili

4 REPLIES 4
howarder
Obsidian | Level 7

Hi Barbara,

 

Here is a paper that talks about how to create page numbers with ods output. http://support.sas.com/resources/papers/proceedings11/263-2011.pdf

 

There is an example of how to create them as a title. The code is as follows using the ods escapechar option.

 

OPTIONS NONUMBER;
ODS ESCAPECHAR='^';
title justify=center 'Data Set CLIPS'
 justify=right 'Page ^{pageof}'; 

 Hopefully this helps you out. 

Cynthia_sas
SAS Super FREQ

Hi:

I think the challenge that the OP will ultimately face is that the usual {thispage} and {lastpage} ESCAPECHAR functions only work with the page numbering for the total number of pages in the document (not the number of pages relative to each table. (BTW, {pageof} only works for RTF, not for PDF, but {thispage} and {lastpage} work for both RTF and PDF destinations.)

 

  That means for page x of y -- x is the current page and y is the number of pages in the entire document.

 

  For example, in the code below, multiple pages are printed for SASHELP.HEART and SASHELP.SHOES and you can see at the "change" between the procedures that it was possible to reset the starting value for {thispage} but not for the ending value of {lastpage}.

 

cynthia

 

here's the code:

title; footnote;
ods escapechar='^';

options pageno=1;
ods rtf file='c:\temp\multpages.rtf';
ods pdf file='c:\temp\multpages.pdf';

title j=c "SASHELP.HEART" j=r 'Page ^{thispage} of ^{lastpage}';
proc print data=sashelp.heart(obs=100);
  var sex status ageatstart diastolic systolic;
run;
title;
 
options pageno=1;
ods rtf;
ods pdf;

title j=l 'Page ^{thispage} of ^{lastpage}' j=c "SASHELP.SHOES";

proc print data=sashelp.shoes(obs=150);
  var region product sales inventory;
run;

ods _all_ close;
title;

and the output (top output is PDF, bottom output is RTF):

using_page_numbering.png

DrAbhijeetSafai
Pyrite | Level 9
Thanks.
Dr. Abhijeet Safai
Associate Data Analyst
Actu-Real
Jianmin
Obsidian | Level 7

Hi @COMPAREMISSING , a short answer to your question is YES.  But according to the SAS export @Cynthia_sas , you would not have a SAS solution in any time soon (I can be wrong). 

 

I understand your motivation for this project, and the good news is that the method is out there for quite a long time.  Here is an example for you to start, using a modified program from @Cynthia_sas , and a short description of the method is in a SAS Global Forum 2020 paper.   Good Luck and Happy New Year!

title; footnote;
ods escapechar='^';

data heart; set sashelp.heart(obs=100);
pg=1+floor(_n_/35); 

data shoes; set sashelp.shoes(obs=150);; 
pg=1+floor(_n_/35); 

options pageno=1;
ods rtf file='~/sasout/multpages.rtf';

title j=c "SASHELP.HEART" j=r 'Page ^{thispage} of ^{lastpage}' j=l 'PAGE_X_OF_Y';
proc  report data=heart; 
  col pg sex status ageatstart diastolic systolic;
  define pg /order order=internal noprint;
  break after pg/page;
run;
title;
 
title j=l 'Page ^{thispage} of ^{lastpage}' j=c "SASHELP.SHOES" j=r 'PAGE_X_OF_Y'; 
proc report data=shoes;
  col pg region product sales inventory;
  define pg /order order=internal noprint;
  break after pg/page;
run;

ods _all_ close;
title;

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
  • 4 replies
  • 7610 views
  • 2 likes
  • 5 in conversation