The SAS Output Delivery System and reporting techniques

Ods rtf proc tabulate - how to get continued message for multipages tables?

Reply
Occasional Contributor
Posts: 12

Ods rtf proc tabulate - how to get continued message for multipages tables?

I'm using ods rtf proc tabulate to create a table. How to get continued message for multipages tables in RTF?

Thanks!

Clara

SAS Super FREQ
Posts: 8,719

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi:

  If you use the newer TAGSETS.RTF destination, you get the word Continued automatically if a table breaks across pages. The example below makes data that will split across 2 pages. The TAGSETS.RTF output file has the Continued string at the bottom of page 1.

cynthia

data cats;
do Biggrp = 'a1', 'b1', 'c1', 'd1';
  do Cat = 'aaa', 'bbb', 'ccc', 'ddd';
     do Subcat = 'xx', 'yy', 'zz';
       do Gender = 'F', 'M';
         do Value = 1 to 100;
             if ranuni(value) le .5 then output;
         end;
       end;
     end;
  end;
end;
run;
    
ods listing close;
ods rtf file='c:\temp\orig_no_continued.rtf';
ods tagsets.rtf file='c:\temp\new_with_continued.rtf';
  proc tabulate data=cats f=comma10.;
    class biggrp cat subcat gender;
    var value;
    table biggrp*cat*subcat all,
          gender*value*sum=' ' all*value*sum=' ';
    keylabel all='Total';
   run;
ods _all_ close;

Occasional Contributor
Posts: 12

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi Cynthia,

I use a lot of options for ods rtf so that my tables look nice. All that is lost when I use tagsets.rtf. Is there any solution to get the countinued message with ods rtf?

SAS Super FREQ
Posts: 8,719

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi:

  Since you didn't show your code, I did not realize that there were other options you were using. What options are you using with ODS RTF that do not work with TAGSETS.RTF? It could be that an option with ODS RTF got moved to a suboption with TAGSETS.RTF. You can see the list of suboptions that can be used with TAGSETS.RTF by using the doc='Help' suboption, as shown below:

ods tagsets.rtf file='c:\temp\new_with_continued.rtf'

    options(contents='yes' toc_data='yes' doc='Help');

  ... code ...

ods _all_ close;

then, look in your SAS log to see the suboptions that you can use with TAGSETS.RTF. For example, the CONTENTS=YES option with ODS RTF becomes the CONTENTS='YES' suboption with TAGSETS.RTF. On the other hand, if you are using STYLE= overrides in your TABULATE code, those should work with TAGSETS.RTF as well as with ODS RTF.

  Otherwise, there are some options that are not necessary when you use TAGSETS.RTF. For example, BODYTITLE, which was designed for ODS RTF, is not needed with ODS TAGSETS.RTF because your SAS title automatically goes into the body of the document (not in the header) with TAGSETS.RTF.

   The primary difference between ODS RTF and ODS TAGSETS.RTF is exactly the fact that ODS TAGSETS.RTF does do vertical measurement -- so it knows when to put the Continued text string -- whoever opens the file will always see the Continued text string at the bottom of a page. But, for ODS RTF, two different people could receive the same document; each person could change their Word margins after opening the RTF file and each table would split in a different place. So there's not a way with ODS RTF to put a Continued text string. Without seeing an example of what you mean or understanding what options you mean when you say that a "lot of options" don't work, it's hard to provide more helpful advice. You might consider opening a track with Tech Support for more specific help on this issue.

cynthia

Occasional Contributor
Posts: 12

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi,

I use for example  \R/RTF"\line " in my formats to get a blank line. How can I obtain the same with tagsets.rtf?

How could I send you two rtf outputs (with ods rtf and ods tagesets.rtf) of the same table?

Thanks!

Clara

SAS Super FREQ
Posts: 8,719

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi:

  Oh, I see. You are inserting "raw" RTF control strings into your output. I hardly use RAW text insertion anymore. I use ODS ESCAPECHAR and the "newline" functionality that is built into ODS. That way, I can create output that gets a line feed whether I am generating RTF or PDF or HTML output. The "raw" capability only works with HTML and RTF, so it is limiting. I do use RAW text insertion sometimes, if there is an RTF control string that ODS does not have an equivalent for  (like \tab) -- but ODS has a newline capability, so I just don't use the RTF \line anymore.


  However, when I run this sample program (in SAS 9.3) using either ODS RTF or ODS TAGSETS.RTF, I do get the line feed in either file using RAW text insertion(see screenshot) and with ODS ESCAPECHAR. So it is a puzzle why you are not getting a line feed. That would be a question for Tech Support. But, as I said, I prefer to use straight ODS ESCAPECHAR and the NEWLINE escapechar function because I can get line feeds with PDF.

  

  My sample program did not use user-defined formats, but I assume that the format would work the same.
 

cynthia

data class;
  length newvar newvar2 $60;
  set sashelp.class;
  where age le 12;
  newvar = catx('^{newline 1}', name,'xxx yyy zzz',sex);
  newvar2 ="Something" ||
           "^R/RTF'\line' " ||"Else";
run;
  

options nodate nonumber;
** Using ODS ESCAPECHAR for inserting line feeds;
ods listing close;
ods pdf file='c:\temp\useline.pdf';
ods rtf file='c:\temp\orig_useline.rtf';
ods tagsets.rtf file='c:\temp\new_useline2.rtf';
    
ods escapechar='^';
    
  title "My Title ^{newline 1}Using SAS version &sysvlong4";
  proc report data=class nowd;
  column newvar newvar2 name age sex;
  define newvar /display "uses Escapechar";
  define newvar2 / display "uses RAW text insertion"
         style(column)={protectspecialchars=off};
  define name / display;
  compute before _page_ /
          style={just=left font_weight=bold};
    line 'Twas brillig and the slithy toves ^{newline 1}Did gyre and gimble in the wabe';
  endcomp;
run;
ods _all_ close;

Attachment
Occasional Contributor
Posts: 12

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Thank you Cynthia, it was very helpful.

One more question:

why is the text in ods rtf always left?

ODS ESCAPECHAR='^';

ODS RTF FILE="C:\temp\text.rtf" bodytitle;

ods rtf  text="^S={just=left}(continued)";

ods rtf  text="^S={just=center}(continued)";

ODS RTF CLOSE;

How can I change this?

Clara

Grand Advisor
Posts: 10,210

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

I believe the JUST instruction works with the length of the printed line not the page width. See what happens with

 

ods rtf text="^S={just=left}                                (continued)";

ods rtf text="^S={just=center}                           (continued)";

ods rtf text="^S={just=right}                              (continued)";

Notice that the ruler in Word, if using that program to look at results, will indicate the line lengths are about the same and the text is justified within that length.

(watch out for editors stripping multiple spaces!)

Another option you may want to use would be

 

ods rtf text="^S={just=left leftmargin=2.5in}(continued)";

or set other value for how many inches to indent.

SAS Super FREQ
Posts: 8,719

Re: Ods rtf proc tabulate - how to get continued message for multipages tables?

Hi:

  Usually, user supplied text is left justified by default. Sometimes ODS ESCAPECHAR will work with ODS TEXT=. If you run into an instance where ODS TEXT= does not work with ODS ESCAPECHAR method of justification, then you may need to alter the STYLE template used for your destination, as described here: http://support.sas.com/resources/papers/proceedings10/033-2010.pdf on pages 11 and 12.

cynthia

Ask a Question
Discussion stats
  • 8 replies
  • 854 views
  • 0 likes
  • 3 in conversation