BookmarkSubscribeRSS Feed
yanamadala85
Obsidian | Level 7

I have to print page number (page X of Y) at body part of the footnote with "line" statement And the page numbers should not change even if I merge/combine the two rtf files.

Please find the below example program. I need alternative RTF tag/tags for yellow colored tag for printing X and it should not change even after combining two rtf output.

ods escapechar='^';

ods listing close;

ods rtf file='myrtf.rtf';

proc report data=sashelp.class;

title 'Page ^{thispage} of ^{laspg}';

%let lastshet=5;

compute after _page_ / left;

      line "Page ^R/RTF'{\chpgn}' of &lastshet";

endcomp;

run;

ods listing;

ods rtf close;

Note: I should use the rtf tags in line statement.

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

I am afraid the second condition of your request is not possible with tags.  The simple fact is that rtf is text, with tags to describe how to render the text.  When the RTF is loaded, say into Word, the file is interpreted by the RTF parser.  At this point page numbers and such like are calculated.  Hence, if you combine two RTF files, then the page number is calculated "overall".  You could print each RTF file to PDF, then combine those as the print to PDF hardcodes the page numbers into the text.  You can also do this yourself in your code.  Say I have table with 100 rows.  If I fix each page to have 10 rows, then I know that page numbering works 1 of 10 - 10 of 10, and can easliy add this into the data and report it out.  This is again hardcoding the page numbers into the output, so no use of tags for this.

yanamadala85
Obsidian | Level 7

Hi,

In my condition i have to assign page numbers dynamically, I don't have an option to do like the above.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

There is no dynamic tag such as you mention.  If you use the dynamic tags as given, when you combine the RTF files the page numbers will be for the whole document.  You will need to hardcode the page numbers in one way or another to get fixed page numbering.  A document either has dynamic page numbering or fixed page numbering, take your pick.

yanamadala85
Obsidian | Level 7

I am planning to use the below tag but it is not getting resolve, Can you please guide me?

ods escapechar='^';

ods listing close;

ods rtf file='myrtf.rtf';

proc report data=sashelp.class;

title 'Page ^{thispage} of ^{laspg}';

run;

ods RTF TEXT= "^R/RTF'{/sectd /pgnstart}";

ods listing;

ods rtf close;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

You have a typo in that:

ods RTF TEXT= "^R/RTF{'/sectd /pgnstart'}";

Don't think this will help though, it may (you will have to try) reset the page numbering back to 1, but its still a calculated not fixed page numbering.

crow
Fluorite | Level 6
title 'Page ^{thispage} of ^{lastpage}';

works fine for me (in RTF of course).

Cynthia_sas
SAS Super FREQ

Hi:
You are using "old" pre-9.2 version syntax for inserting "raw" RTF control strings into your output. I do not know how long this older syntax will be supported. As you have been advised, when ODS makes an RTF file using your "raw" strings, ODS is just inserting control strings into an ASCII text file.It is up to the Word Processor that opens the RTF file to use the control strings as designed.

 

  If you combine the 2 RTF files, the word processor that renders the RTF control strings will "resolve" the page numbering controls. It is likely that the page numbers will change based on the way that the word processor renders the page controls. But if you have one RTF file with 10 pages that initially shows page 1 of 10 and a second RTF file that initially shows page 1 of 15, when you combine those files, the first pages, from the first RTF file will probably show 1 of 25 and the second RTF file, now combined with the first will probably show page 11 of 25. If I understand what you are trying to do, you cannot use RTF control strings with ODS to "freeze" the page numbers and bypass how the word processor will treat the RTF controls.

Cynthia

crow
Fluorite | Level 6
Hi!

Yes, you are right! The word processor is responsible for page numbering in such case. It was not necessary for me to join rtf files, so I did not think in such way you just pointed out. I know the way to do it in plain TXT output (did it many years ago). I made an output file with some marks inside, for example «$PAGE$», and processed it after with "data _null_" and so on, but it should not be a case, I suspect… but possible to try. Let me know if you are interested in it (will try to find the code).

Best regards,
Crow
Cynthia_sas
SAS Super FREQ
Hi:
That was the technique that we used to recommend for both RTF and PostScript before the ODS ESCAPECHAR and page X of Y page numbering with ESCAPECHAR functions.

Back in Version 8, I believe there was even an example in the Tech Support notes, but it may not be available anymore.

cynthia

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!

How to Concatenate Values

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.

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
  • 9 replies
  • 7547 views
  • 1 like
  • 4 in conversation