I am post-processing RTF code to "translate" Page X of Y of individual RTF files. I found that one RTF file has 8 total physical pages, but only six instances of the RTF code of interest:
{\field{\*\fldinst { PAGE }}} of {\field{\*\fldinst { NUMPAGES }}}
Two pages that spillover inherit this footer. The input data set has a PAGE_2 variable intended to stop sections from breaking across pages, but several sections have too many rows and spill over. The REPORT code of interest is:
break after page_order_2 / page ;
The original RTF file is:
Though truncated, the bottom page shown is "Page 5 of 8". The RTF code corresponding to a "valid" page break is:
\pard\plain\intbl\sb0\sa0\ql\f1\fs18\cf1\li68{Min, Max\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
\pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell}
{\row}
\pard
\sect\sectd\linex0\endnhere\pgwsxn15840\pghsxn12240\lndscpsxn\headery1080\footery1080\marglsxn1080\margrsxn1080\margtsxn1080\margbsxn1080
{\header\pard\plain\qc{
\trowd\trkeep\trql
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx6834
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx13678
\pard\plain\intbl\sb10\sa10\ql\f1\fs18\cf1{xxxx\cell}
\pard\plain\intbl\sb10\sa10\qr\f1\fs18\cf1{Data Extraction Date: xxxx\cell}
{\row}
<SNIPPED>
\trowd\trkeep\trql
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx13678
\pard\plain\intbl\sb10\sa10\qc\f1\fs18\cf1{Safety Population\cell}
{\row}
\pard{\par}}}
{\footer\pard\plain\qc{
{\par}\trowd\trkeep\trql
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx13630
\pard\plain\intbl\sb10\sa10\ql\f1\fs18\cf1{xxxx\cell}
{\row}
<SNIPPED>
\trowd\trkeep\trql
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx6810
\cltxlrtb\clvertalt\clcbpat8\clpadt10\clpadft3\clpadr10\clpadfr3\cellx13630
\pard\plain\intbl\sb10\sa10\ql\f1\fs18\cf1{Confidential\cell}
\pard\plain\intbl\sb10\sa10\qr\f1\fs18\cf1{Page {\field{\*\fldinst { PAGE }}} of {\field{\*\fldinst { NUMPAGES }}}\cell}
{\row}
\pard}}{\upr{\*\bkmkstart IDX3}{\*\ud{\*\bkmkstart IDX3}}}{\*\bkmkend IDX3}\trowd\trkeep\trhdr\trql
The RTF code corresponding the spillover and not the break is:
\pard\plain\intbl\sb0\sa0\ql\f1\fs18\cf1\li68{Mean (SD)\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} {\row} \trowd\trkeep\trql \cltxlrtb\clvertalc\clcbpat8\cellx2688 \cltxlrtb\clvertalc\clcbpat8\cellx4191 \cltxlrtb\clvertalc\clcbpat8\cellx5694 \cltxlrtb\clvertalc\clcbpat8\cellx7197 \cltxlrtb\clvertalc\clcbpat8\cellx8700 \cltxlrtb\clvertalc\clcbpat8\cellx10203 \cltxlrtb\clvertalc\clcbpat8\cellx11706 \cltxlrtb\clvertalc\clcbpat8\cellx13657 \pard\plain\intbl\keepn\sb0\sa0\ql\f1\fs18\cf1\li68{Median (Q1, Q3)\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} \pard\plain\intbl\keepn\sb0\sa0\qc\f1\fs18\cf1{YYYY\cell} {\row} \trowd\trkeep\trql
I cannot discern a marker to add code so that "Page 4 of 6" does not repeat over the this page and correctly calculates as "Page 4 of 8" and "Page 5 of 8".
Might anyone have some advice or references? This is for internal purposes, so upper managers might over look that issue, but if I could count physical pages, then the team would be happier.
Thank you,
Kevin
Hi, seeing your single line of PROC REPORT code without seeing ALL the code and ALL the data makes it hard to make a constructive comment. Off the top of my head, I would make sure that the PAGE_2 variable or an automatic break or BY group is not conflicting. You probably have tried tagsets.rtf. I have heard in the past that post-processing RTF files to combine them together can be difficult. (not a suggestion not to try it just an observation that folks who have tried it and succeeded have remarked how hard it was to work out)
My other suggestion would be to open a case with Tech Support where they can look at ALL your code and your data and try to help you figure out where the output is breaking.
Cynthia
Cynthia,
As you might imagine, I would have to simulate data to share. Possible, but I am not sure that my employer would allow me to, except on my own time. Unfortunately, I have to work with the RTF files that I have, they would not be interested in a "re-work" for this purpose. Since they want the titles and footnotes in the header and footer, I returned to ODS RTF destination.
Combining RTF files challenges many people. From the papers that I have seen, I am not sure that anyone is covering FONTTBL and COLORTBL differences. The DOCUMENT approach seems appealing, but they did not implement it (and I had "trouble" with the titles and footnotes for graphs).
Thank you,
Kevin
Probably because there should NOT be an extra line in the RTF file.
RTF files are not like PDF files. PDF files are page oriented so that you can print it exactly the same way on many different devices. An RTF file is just a markup language for specifying what you want and the exact results will depend on what device you will use to print it. So when a table or paragraph spans pages 4 and 5 there is no need to insert any extra code to say what to print as the footer on page 4 or the header on page 5.
Instead of trying to hard code the page number or the total number of pages you should be inserting the RTF function that calculates the current page and the number of pages.
Tom,
Thank you for responding. I am not sure what you mean by "extra line". If you mean a line return in the RTF code, I added it manually in a copy to readability or to "anchor" that section.
I am working with the RTF files I received, not the programs that generated them. I did explain to my stakeholders that the results will depend on the software "rendering" the RTF code. The reason is that they want to combine 100-150 RTF files, some with lengths over 1000-2000 pages, but they want to preserve the original page numbering of the individual files. I have also added bookmarks and hyperlinks for a ToC, which is of a varying number of pages.
If you know of a RTF function, then I would be happy to explore it. RTF is a pretty bad language, especially if one wants to extract the data, but I have not been able to programmatically read PDF, so at least it is not horrendous.
Thank you,
Kevin
No. If you look at an RTF file that produces TITLE and FOOTNOTE lines there is some line of code that includes that title. So say you an RTF file that consisted of a TITLE and 124 paragraphs. It might fit on 10 pages or 50 pages depending on the length of the paragraphs, the margin, the fonts, the driver for the device you are printing to. But in the file you would just see something like this:
title goes here
paragraph1
paragraph2
....
paragraph124
See this old discussion from about 13 years ago: https://communities.sas.com/t5/ODS-and-Base-Reporting/Getting-Page-X-of-Y-in-Body-of-the-RTF/m-p/444...
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.