Hi,
I am trying to add page numbers to the footnote section on every page of a RTF file. This RTF has a table of contents and then multiple tables. My page will not start with 1, as the RTF file is to be appended to another file that has 213 pages.
I am able to replicate the result from this post Page number at top and page break after each proc report entry and to change the pageno= option to a number other than 1. It works in both PDF and RTF files. I've tried to modify my own script files by adding this to my master script
options PAGENO=214
and
FOOTNOTE J=center
font='Times New Roman'
h=10pt
"^{thispage}"
;
to individual table script files that are executed by the master script. Unfortunately, adding the pageno=214 has no effect on the starting page number. My starting page number always appears as 1. I don't know if this has something to do with my table of contents. I have 19 table script files to be run within the master script file. I hope there is no need to hard-code page number in each table script file. Any working code would be highly appreciated. Thanks
My master script that generates just 1 table:
options PAGENO=214 /*Starting page number for the next page*/
missing = ' ' /*Specifies the character to print for missing numeric values.*/
center /*Specifies whether to center or left align SAS procedure output*/
nodate /*suppress default print of data time that this SAS program executed*/
nonumber /*nonumber: suppress default print of page number on first title line of each page*/
orientation= landscape /*orientation=portrait */
;
TITLE1; TITLE2;
/*------------------------------------------------------changing table margins------------------------------------------------------*/
options bottommargin = 2 cm
topmargin = 2 cm
rightmargin = 2 cm
leftmargin = 2 cm
;
/*suppress the warning that a quoted string that exceeds 262 characters in length*/
options NOQUOTELENMAX ;
/*Store table title text CSV file in SAS macro variables and values*/
%include "&SAS_script_dir.\supp-table-title-text_to_SAS-macro-var.sas" ;
%include "&SAS_script_dir.\import_supplementary-table_table-of-contents.sas" ;
/* first tell ODS what character will be used as the ODS ESCAPECHAR character value*/
ods escapechar='~';
ods escapechar='^';
ods _all_ close;
ods rtf file= "&report_dir.\PhD-thesis_supplementary-tables_%sysfunc(date(), yymmdd10.).rtf"
style= Journal
contents
toc_data /*contents toc_data: show table of contents*/
;
/*------ Table 1 script---------*/
%let table_order = 1;
%let tData_uniVarBin_t1t2Count= output.manu1_count_twin_paris ;
%let tScript_uniVarBin_t1t2Count= Ch2_tabSup01_count-twin-pairs_binary-outcomes;
%include "&destin_script_dir.\&tScript_uniVarBin_t1t2Count..sas";
/*------------------ close ODS RTF device----------------------------------------------------*/
ods rtf close;
ods listing;
My Table 1 script:
/*---------------------------------------------------------------import data into SAS-------------------------------------------------------*/
data output.chapter2_tableSup&table_order.; /*old table name: out._NU_table_08b3 tem._NU_manuscript01_table01*/
set &tData_uniVarBin_t1t2Count. ;
gap01=''; /*add gap01, gap02 for inserting blank in PROC REPORT*/
gap02='';
gap03='';
/*Create a dummy variable to remove third node. This node iscontrolled by the BREAK BEFORE statement*/
report_3rd_node_breaker=1;
OBSNO=_N_;
run;
/*--------------------------------Add titles and footnotes----------------------------------------------------------*/
proc sort data= output.chapter2_tableSup&table_order.; by report_3rd_node_breaker; run;
/*Get text for the 1st node of Table of Contents from a SAS macro variable
The first node is controlled with the ODS PROCLABEL statement.
*/
ODS PROCLABEL="&&chapter2_suppTableContent&table_order." ;
/*TITLE and FOOTNOTE
By default, titles and footnotes are both bold and italic. When you change the font, you also turn off the bold and italic features. You can turn them on
by using the BOLD and ITALIC options. There is no option to turn off boldness and italics, so if you wish to turn them off, use the FONT= option.
*/
/*Add table title using SAS macro variable read from an external CSV file*/
title4 J=L
font='Times New Roman'
h=10pt
"&&chapter2_tableSuppTitle&table_order."
;
/*Add page number in the footnote section
{thispage} is an internal variable that would automatically count the current page number
*/
FOOTNOTE J=center
font='Times New Roman'
h=10pt
"^{thispage}"
;
/*-----------------------------------------------------------Add table body-----------------------------------------------------------*/
/*The 2nd node of table of contents is controlled with the CONTENTS= option on the PROC REPORT statement. Here CONTENTS="" removed the node entirely*/
proc report data=output.chapter2_tableSup&table_order.
contents="" /*Remove default 2nd node from the Table of contents*/
nowd
split='|'
style(report)={width=100%
cellpadding=8px
font_face='Times New Roman'
font_size=10pt
borderwidth=1.5pt /* border thickness*/
background = TRANSPARENT}
style(header)={just=left
font_weight=bold
font_face='Times New Roman'
font_size=10pt
font_style=roman
protectspecialchars = OFF
background = TRANSPARENT}
style(column)={font_face='Times New Roman'
font_size=10pt
background = TRANSPARENT}
;
/*The COLUMN statement is used to list each report column
The breaking variable report_3rd_node_breaker needs to be the first thing on the COLUMN statement to get rid of the Table 1 node.
*/
column report_3rd_node_breaker varGroup OBSNO depVar
gap01 /*insert a gap between columns with two-level headers*/
("\brdrb\brdrdot\brdrw5\brdrcf1 MZ twin pairs (twin1, twin2)"
twinCPair_MZ_0_0 twinCPair_MZ_0_1 twinCPair_MZ_1_0 twinCPair_MZ_1_1 )
gap02 /*insert a gap between columns with two-level headers*/
("\brdrb\brdrdot\brdrw5\brdrcf1 DZ twin pairs (twin1, twin2)"
twinCPair_DZ_0_0 twinCPair_DZ_0_1 twinCPair_DZ_1_0 twinCPair_DZ_1_1 )
gap03
sum_completePairs N_twinNonMissDepVar;
/*Each column, in turn, has a DEFINE statement that describes how that column is created and formatted.*/
%def_group( cVar=varGroup /*variable name*/
,option=group /*specify option=order if to order data alphabeticall; = group if not to order data*/
,cName=Scale /*column header*/
,cWide=2 cm
,headerAlign=left /*alignment of header text in a column: left, center, right*/
,colAlign=left /*alignment of content in a column: left, center, right, d (decimal point) */
);
DEFINE report_3rd_node_breaker / NOPRINT ORDER;
DEFINE OBSNO / ORDER NOPRINT;
%def_display( cVar=depVar, cName=Diagnosis, cWide=3.5 cm, headerAlign=left, colAlign=left);
%def_display( cVar=twinCPair_MZ_0_0, cName=(0, 0), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_MZ_0_1, cName=(0, 1), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_MZ_1_0, cName=(1, 0), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_MZ_1_1, cName=(1, 1), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_DZ_0_0, cName=(0, 0), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_DZ_0_1, cName=(0, 1), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_DZ_1_0, cName=(1, 0), cWide=1 cm, headerAlign=right);
%def_display( cVar=twinCPair_DZ_1_1, cName=(1, 1), cWide=1 cm, headerAlign=right);
%def_display( cVar=sum_completePairs, cName=Total twin pairs, cWide=2.5 cm, headerAlign=right);
%def_display( cVar=N_twinNonMissDepVar, cName=Total twin individuals, cWide=1.5 cm, headerAlign=right);
/*Define all the gap variables*/
%def_display( cVar=gap01 ,cName= ,isFmt=N ,cFmt= ,cWide=0.2%);
%def_display( cVar=gap02 ,cName= ,isFmt=N ,cFmt= ,cWide=0.2%);
%def_display( cVar=gap03 ,cName= ,isFmt=N ,cFmt= ,cWide=0.2%);
/*Add horitzontal lines under every occurence of dependent variable column*/
compute varGroup;
if varGroup not="" then call define (_row_
,'style'
,'style={bordertopcolor=cyan bordertopwidth=1}');
endcomp;
compute after _page_ /style={just=l
font_size=10pt
font_face='Times New Roman'
borderbottomcolor=white
bordertopcolor=black};
endcomp;
/*Remove 3rd node in the Table of contents*/
BREAK BEFORE report_3rd_node_breaker/ page contents="";
run;
Hi:
Without data, no one can really help you. Have you checked for OPTIONS statements in the included programs that might reset the pageno option?
The best resource for you is Tech Support. They will need to look at ALL your code and have some sample data so they can run your code to determine what the issue is.
When I run a simple test, on SASHELP datasets, it seems as though PAGENO is working as designed. See example below:
Cynthia
Hi Cynthia,
Thanks for checking my code. I don't have OPTIONS statements in my included script files. I generally don't include global setting in script files to be included in my master script.
I've done a test leaving out the table of contents. The starting page number was changed successfully. Perhaps the TOC is the culprit. If the TOC will reset pageno= option , I would suggest this default be able to change by users in future SAS.
Cheers,
Chang
Maybe some clarification is in order.
Is the TOC page showing Page 1? Is there any procedure output on that page, or only TOC entries?
The TOC page is not showing any page number. Page 1 appears on the next page, where my first table is placed. I cannot see any procedure output on the TOC page:
Hi: I'm confused. the TOC page is ALWAYS a separate page by itself. You never see procedure output on the TOC page, you always see the contents when you do an update field on the first page. The first procedure always starts on a separate page, as shown below:
Cynthia
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.