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
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.
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):
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.