Practical Solutions for Pagination, Indention, and Mixed-Text Alignment in ODS RTF Word Documents Hui Song, PRA International, Horsham, PA

Practical Solutions for Pagination, Indention, and Mixed-Text Alignment in ODS RTF Word Documents Hui Song, PRA International, Horsham, PA

Practical Solutions for Pagination, Indention, and Mixed-Text Alignment in ODS RTF Word Documents Hui Song, PRA International, Horsham, PA ABSTRACT The ODS rich-text format (RTF) destination, together with PROC REPORT, makes it possible to produce high-quality, informative, statistical reports, that conform to the FDA CSR submission guidance. However, PROC REPORT misses critical features such as pagination to make customized reports. Text wrapping within the RTF table cells (or listing) makes this task hard to accomplish. Sometimes, for ease of reading, we need to add a category ended with ‘Continued’ at the top of the following pages when the category spreads across multiple pages. These kinds of requirements make the pagination even harder to achieve. On the other hand, Since SAS® no longer has full control of the RFT’s layout when using ODS RTF destination, to indent and align mixed text (such as xx.xxx (xx.x %)) also becomes more challenging. This paper presents several practical solutions to address the above mentioned issues and produce good- quality reports in RTF format. INTRODUCTION In addition to conform to the FDA guidance, the pharmaceutical community is striving to produce high- quality and informative statistical reports in the FDA CSR submission package. This effort becomes more doable, with the introduction of ODS rich-text format (RTF) destination. With the rich set of RTF formatting commands, together with PROC REPORT, clinical programmers can produce good-quality table and listing reports. Depended on clinical studies, the statistical reports are often highly customized per statistical analysis purpose. The report needs to be paginated for easily reading and understanding. Sometimes, we need to add some extra lines of information to make the report easy to follow. For example, if the items below a category (such as preferred terms under a body organ class) spread across multiple pages, we should add the category (ended with ‘Continued’) to the following pages to make it easy for the reviewers to follow. In other times, a long text (e.g., comments) will wrap within a table cell when RTF format is used, expending to multiple lines. Since PROC REPORT itself does not provide a pagination mechanism directly, these customizing requirements make it even hard to accomplish the pagination nicely. On the other hand, with ODS RTF destination facility, SAS no longer has full control of the layout of the output. Text indention and mixed-text alignment (such xx.xxx (xx.x %)) could become very time consuming in the TFL producing process when generating the output as rich-text format (RTF) Word document. In this paper, we provide several practical solutions (including useful SAS tricks and RTF formatting commands) to address the above mentioned issues and produce good-quality reports in RTF format. Sample codes will be provided and can be easily revised and used in the daily TFL production work for clinical programmers. BASICS FOR ODS RTF STYLE AND COMMANDS A good and concise introduction of ODS RTF destination can be found in the first reference (SAS, The RTF Destination). Here we just give a short summary. RTF specification is a method to encode formatted text and graphics. An RTF file consists of unformatted text, control words, control symbols, and groups. A control word is a specially formatted command that RTF uses to mark printer control codes and information that Word application uses to manage documents. A control word takes the format of \LetterSequence<Delimiter>. A backslash begins each control word. The LetterSequence is made up of lowercase alphabetic characters (a-z). RTF is case sensitive. Some control words (such as bold and 1 italic) have only two states. A control word with a parameter of 0 is used to turns off the property. For example, \b turns on bold, whereas \b0 turns off bold. Table 1 listed some frequently-used control words. Table 1: RTF Control Word Style RTF Control Word Italicize \i Underline \ul New line \line Subscript \sub Superscript \super Bold \b Left aligned \ql Right aligned \qr centered \qc A control symbol consists of a backslash followed by a single, nonalphabetic character. For example, \~ represents a nonbreaking space. Control symbols take no delimiters. A group consists of text and control words or control symbols enclosed in braces ({}). Each group specifies the text affected by the group and the different attributes of that text. The RTF file can include groups for fonts, styles, color, pictures, footnotes, comments, headers and footers, as well as document-, section-, paragraph-, and character- formatting properties. Formatting specified within a group affects only the text within that group. Based on RTF specification, PROC TEMPLATE is used to create global styles for titles, footnotes, colors, fonts, margins, etc. In addition, one can embed RTF commands in SAS code to format the text by controlling the style, color, font, and so forth. This is often referred to as In-Line Formatting. A good paper on this topic is reference (Parsons 2007). To use in-line formatting, you first define an escape character with the ODS statement: ODS ESCAPECHAR =‘escape-character’;. The ‘^’ character is a safe one and is used in Table 2, excerpted from (Parsons 2007), which is listed here for quick reference. Table 2: In-Line Formatting Code SAS Option Function Modifies the style of the current paragraph or cell. The syntax is just like that of the style={} syntax in table templates and PROCs REPORT and TABULATE except that no style element is supported to the left of ^S={style-attributes} the {}s. A specialized case of the above; reverts the style to the style of the ^S={} paragraph. ^{super text} Put text into a superscript. ^{sub text} Put text into a subscript. ^{dagger} Print the "dagger" character. ^n Inserts a new line. Marks a good place for an optional line-break. Doesn't force a new ^w line, but "suggests" it as a good place if the line must be wrapped. ^_ Inserts a non-breaking space. In the literature, there are several other good papers presenting the tricks and tips of using RTF commands to control the format of the text in the output, such as (Shannon 2002) and (Rachabattula 2010), just to name a few. In this paper, we will focus on the areas where the RTF formatting is more 2 challenging due to SAS losing partial of the layout control of the output, including pagination, indention, mixed-text alignment, etc. PAGINATION IN PROC REPORT With RTF ODS facility and PROC TEMPLATE, PROC REPORT is used to produce the tables, figures, and listings (TFLs). The pagination is done automatically by the RTF applications (such as MS Word) when rendering a RTF document and displaying it. The application program will decide when and where a new page will begin. In this sense, SAS has lost partial of the layout control of the RTF output. In fact, PROC REPORT itself does not have a direct option to provide correct pagination for customized reports within ODS. More specifically, when creating TFLs via the ODS, the number of lines per page can be determined in advance. However, due to text wrapping, there is no direct option to calculate the number of lines needed per observation in such situation. Text wrapping can cause elements that should be displayed together on the same page to split over two or more pages. Moreover, sometimes, we need to force starting a new page when presenting a new group of information (e.g., AEBODSYS or USUBJID). Thus, Manual pagination control is needed, to some extent, to determine where the pagination occurs. In this section, we present a simple technique that can manually control the pagination in RTF output. The sample code can be easily revised and enhanced to fit different TFL presentation requirements. The basic idea is as follows (illustrated in Table 3). First, count the number of rows per observation that each text-wrapping column variable requires given the respective cell widths. Second, add the maximum rows needed for each observation and add it to the line counter (Step 1). Third, consider some variables that may add additional lines to the table (such as skip variables in PROC REPORT) (Step 2). Fourth, calculate the number of rows needed and apply it to a variable used by PROC REPORT to determine the desired page breaks (Step 3). Finally, a pagination variable is created for PROC REPORT (Step 4). Additional explanation can be seen in the comments in the code. Note, to save space, we sometimes put more than one statement in the same row. This practice is not encouraged though. Table 3: Pagination by Counting Lines Manually data outDS; set inDS; by studyid usubjid SKIPVAR other_sort_variables ; retain LINECNT 0 MAXN 30; *<---adjust MAXN per the number of rows used by title and footnotes; ** Step 1: some variables (e.g., VAR1 and VAR2) may span over multiples rows, count here **; len1=1; len2=1; if VAR1 ne ' ' then len1= ceil(length((VAR1))/WID1); *<--check VAR1 in output to find its width WID1; if VAR2 ne ' ' then len2= ceil(length((VAR2))/WID2); *<--check VAR2 in output to find its width WID2; LINECNT+max(len1,len2,1); *<---more text-wrapping variables can be added here; ** Step 2: skipped lines counted here (e.g., SKIPVAR is a skip variable in PROC REPORT) **; if first.skipvar then LINECNT+1; ** Step 3 and 4: other special paging needs or when LINECNT is larger than page size, page break **; if first.usubjid or LINECNT >=MAXN then do; PAGEIT+1; LINECNT=0; end; run; 3 Within the PROC REPORT procedure, PAGEIT is used as page break ORDER or GROUP variable. This variable follows a BREAK statement as shown below: break after pageit / page; The sample code in Table 3 can be easily adapted or enhanced for different table presentation requirements or rewritten into a macro.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    7 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us