BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

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

HEADER
data
Page 1 of 4
..
.
.
data
Page 2 of 4
.
.
.
.
data
Page 4 of 4
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
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:
[pre]
options nodate nonumber;
ods rtf file='c:\temp\xofy.rtf';
ods pdf file='c:\temp\xofy.pdf';
ods escapechar='~';
proc print data=sashelp.shoes (obs=200);
var region product sales;
footnote 'Page ~{thispage} of ~{lastpage}';
run;
ods pdf close;
ods rtf close;
[/pre]

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:
[pre]
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}
[/pre]
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:
http://support.sas.com/rnd/base/topics/odsprinter/
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.

cynthia
vcarrion
Calcite | Level 5

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4307 views
  • 0 likes
  • 3 in conversation