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
SAS Super FREQ
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?

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 3617 views
  • 0 likes
  • 3 in conversation