BookmarkSubscribeRSS Feed
yanamadala85
Obsidian | Level 7

I am using The below RTF tag to print the page number(page x of y) in the body part of the RTF file.
   Page ^R/RTF'{\chpgn}' of &laspg

Note: &laspg is the macro variable which i have assigned to the value for Y calculation and i do not have problem with this. I have a problem with '{\chpgn}' tag. Because after merging the two rtf files, page numbers which are present at the body part of the rtf files were changing, I wanted page numbers should not be change at body part of the footnote even after combining the two or three rtf outputs.

With thanks

venkatesh

9 REPLIES 9
jakarman
Barite | Level 11

check RTF specs at: Appendix B: Index of RTF Control Words

---->-- ja karman --<-----
Reeza
Super User

So you have a program that generates Page X of Y notations, using RTF tags where the X is \chpgn and is an RTF tag.

It works if you export a single document.

When you then merge that document into another document, into the middle or end I'm assuming, the page is automatically updated to reflect the current position in the document. This makes perfect sense since the RTF tag is \chpgn uses the current page number.

If I was doing this manually, I would create different sections and there's an option for separate page numbering for each section so I would fix my merging of documents so that each was it's own section and that might avoid this problem. 

Other things to try are for the first page:

\pgnstartN


Or use

\Sect

in your RTF code to create an RTF that has a unique section. 

You may need a combination of the above to get it to work.

Hope that helps.

yanamadala85
Obsidian | Level 7

Hi Reeza,

Thank you for you valuable suggestion, I think it would solve my problem.

In your answer you have mentioned about an"option for separate page numbering for each section", Could you please explain about it and how can I use with an example.

With thanks,

Venkatesh

Reeza
Super User

That depends on how you're combining your files.  If it was in MS Word you could create a Section Break before each section. 

For SAS you could try adding the /sect tag at the beginning of your report.

yanamadala85
Obsidian | Level 7

Please find the below and provide the alternative tag for Page X, that tag must resolve in line statement of compute block.

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;

yanamadala85
Obsidian | Level 7

Hi Reeza,


\pgnstartN

\Sect                tags are not resolving in the compute block.

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'{\pgnstartN}' of &lastshet";

endcomp;

run;

ods listing;

ods rtf close;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Why not just fix it yourself in the data prior to output?  E.g. in your output dataset:

X     Y     Z     Page     Of

X     Y     Z     1           10

X     Y     Z     1           10

X     Y     Z     1           10

X     Y     Z     2           10

Then you can achieve your desired output by using proc report, breaking after Page.

yanamadala85
Obsidian | Level 7

it may solves the problem, but I in my condition I am assigning page values dynamically and I have a calculated program for Y. Only option I have is to use rtf tag for printing of X.

Reeza
Super User

So I tried it manually, e.g. by creating some individual RTF files and then appending them and seeing what tags I needed to get the page numbers in each section to start renumbering.  You can do the same to see what tags you need.

It looks like you need a /sect AND /sectd /pgnstart to set each section of your code, this does not become part of your Proc Report code, that stays the same.

The code below isn't exact and is untested but I think it should look something like

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

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

proc report code....

run;

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

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 9 replies
  • 2364 views
  • 0 likes
  • 4 in conversation