With thanks
venkatesh
check RTF specs at: Appendix B: Index of RTF Control Words
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.
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
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.
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;
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;
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.
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.
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}";
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!
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.
Ready to level-up your skills? Choose your own adventure.