Desktop productivity for business analysts and programmers

Inserting Page X of Y in Footer of Text file

Posts: 0

Inserting Page X of Y in Footer of Text file


I am printing EG project output into that text file.
I want to insert "Page X of Y" into footer of text output.
Text file have 4 pages
I want output like

Page 1 of 4
Page 2 of 4
Page 4 of 4
Posts: 9,253

Re: Inserting Page X of Y in Footer of Text file

Posted in reply to deleted_user
You CAN get page X of Y page numbering in PDF and RTF result files in EG, but NOT for HTML or TEXT (SAS Listing) output in EG:

For example, if you run this code in an EG code node:
options nodate nonumber;
ods rtf file='c:\temp\xofy.rtf';
ods pdf file='c:\temp\xofy.pdf';
ods escapechar='~';
proc print (obs=200);
var region product sales;
footnote 'Page ~{thispage} of ~{lastpage}';
ods pdf close;
ods rtf close;

Then you will see how the page numbers get put into the output with batch code. You can get the same kind of page numbering from your EG tasks, by changing the task code.

To add Page X of Y to an EG project, you would have to:
1) change your Result type so that PDF and/or RTF files are created
(under Tools--> Options)
2) turn off SAS option for numbering and use the ODS ESCAPECHAR statement to "turn on" recognition of the special strings {thispage} and {lastpage}. The reason you are turning off SAS numbering is that SAS only wants to put numbers in the upper right hand corner. So you need to turn that off (probably the date too) so you can use the special ESCAPECHAR strings in your footnote. Then you also have to tell SAS what the special ESCAPECHAR is going to be.
--> Preview your task code then click "Insert Code"
--> At the very top of your code, type:
options nodate nonumber;
ods escapechar='~'; [/pre]
3) make sure the footnote string in your task is:[pre]
Page ~{thispage} of ~{lastpage} [/pre]
At this point, you have to use the same special 'escape character' -- which in the above instance is the tilde (~) -- as you used in the ODS ESCAPECHAR statement. So if I had this:[pre]
ods escapechar='#';
then my footnote text would be:
Page #{thispage} of #{lastpage}
4) Run or Save and run the task

Since HTML does not produced a "paged" file, you will not see any page numbers in the default EG HTML output. You will only see page numbers in the footnote of any RTF and PDF files that you create.

It -is- possible to get Page X of Y page numbering in a SAS Listing file (which is just an ASCII text file), however the technique requires using SAS macros which were user-contributed and therefore, you have to use them at your own risk. Refer to this site:
and look for the section entitled "Archive: Version 8".

The new way of doing Page X of Y with ODS ESCAPECHAR and {thispage} and/or {lastpage} is much easier than any of the macro methods that were formerly required.

For more help with Page X of Y page numbering and EG, your best bet is to contact SAS Tech Support.

Posts: 1

Re: Inserting Page X of Y in Footer of Text file

Posted in reply to Cynthia_sas

umm.. I have not been succesful in implementing this. Any other thoughts? Is it version dependent?

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation