BookmarkSubscribeRSS Feed
CarolV
Fluorite | Level 6

I'm using SAS 9.4. Placing the following code:

 

ods rtf text = "Here is some random text.";

 

between 2 proc report blocks, creates that text as a single cell (with invisible boarders) in the rtf instead of as lines of plain text (see attachment). That cell then must be manually converted to text (using Word "convert table to text" functionality) within Word. Is there a way to insert the text as text instead of as a single celled table?

14 REPLIES 14
Cynthia_sas
SAS Super FREQ

Hi:

  You can turn TABLES_OFF for specific style elements when you use ODS TAGSETS.RTF (instead of the original ODS RTF), as shown below:

tables_off_rtf.png

 

 

  Hope this helps,

Cynthia

ballardw
Super User

Another approach is using Proc ODSTEXT. One difference is that all Proc ODSTEXT goes to all open ODS destinations.

 

Proc odstext;
p "Here is some random text";
run;

Proc ODSTEXT will display text from dataset, style modifications generally are per entire line of text.

 

Both Proc ODSTEXT and ODSLIST will create nice list output

CarolV
Fluorite | Level 6

Thank you for the suggestion. I tried your suggestion, however, using Proc odstext adds the text in a text box instead of directly as a text string. Manual intervention is still needed in Word to select the text box and "Convert to text".

Cynthia_sas
SAS Super FREQ
Hi:
I think in my method, the text is NOT in a text box. I did not have to convert it.
Cynthia
CarolV
Fluorite | Level 6

I'm sure your method is correct, however I am presently struggling with how to implement it. I get the errors:

 

ERROR: Insufficient authorization to access C:\Windows\system32\sasrtf.rtf.

ERROR: Fatal ODS error has occurred. Unable to continue processing this output destination.

WARNING: No body file. RTF output will not be created.

ballardw
Super User

@CarolV wrote:

Thank you for the suggestion. I tried your suggestion, however, using Proc odstext adds the text in a text box instead of directly as a text string. Manual intervention is still needed in Word to select the text box and "Convert to text".


Please show example code, including your ODS destination code, as I do not get anything resembling a text box when I use Proc Odstext with my RTF output.

CarolV
Fluorite | Level 6

This is regarding the Proc odstext suggestion:

 

I have attached the screen shot of the text inserted within the rtf using this method. 

 

Here is my example code:

 

ods noresults;

ods listing close;

 

options nocenter  leftmargin=1.18in rightmargin=1in topmargin=1in bottommargin=1in ps=45;

ods rtf file = "&NewSharePath.\&rpt_name..rtf" startpage=Never;

 

ods escapechar='^';

 

title1 justify = left color = black font = 'Times New Roman' bold HEIGHT=10pt "&titleh"  ;

title2 justify = left color = black font = 'Times New Roman' bold HEIGHT=10pt 'xxxx                                              Section 14 Tables, Figures and Narratives';

 

footnote1 justify = left color = black font = 'Times New Roman' bold HEIGHT=10pt "CONFIDENTIAL AND PROPRIETARY   " 'Page ^{pageof}';

 

  %create_rpt_b;

 

ods rtf close;

 

Within the create_rtp_b macro, between proc reports of 2 tables, the following code was inserted per your suggestion:

 

proc odstext;

  p "here is some random text";

run;

CarolV
Fluorite | Level 6

My attachment as the reply to the proc odstext suggestion does not seem to have displayed. I am reattaching here.

 

<Please note that I am trying to move forward with Cynthia's suggestion, but I can not avoid the ODS errors with that method.>

Cynthia_sas
SAS Super FREQ

Hi:

  I'm not sure what errors you're getting with the code I posted. I am running 9.4 M5 and the code runs without errors for me. If you are using an older version of SAS, the TABLES_OFF suboption might not be available yet.

 

  When I look at my output with Show/Hide Marks turned on, I do not not see a TABLE for my line of text:

show_hide.png

 

  What errors are you getting with the code I posted? Does my code run for you outside of your macro approach?

ods tagsets.rtf file='c:\temp\text_not_in_table.rtf' startpage=no
  options(doc='Help' tables_off='USERTEXT');

proc report data=sashelp.class(obs=3);
  title '1) PROC REPORT';
run;

ods tagsets.rtf text="Twas brillig and the slithy toves did gyre and gimble in the wabe.";

proc print data=sashelp.class(obs=3);
title '2) PROC PRINT';
run;

ods tagsets.rtf close;

Cynthia

CarolV
Fluorite | Level 6

Hi Cynthia,

 

Yes, your code produces the desired result (text not in a table nor in a text box). I have since determined my previous ods errors were caused within the macro portion of the code when I started a new page and forgot to switch from "ods rtf startpage = now;" to "ods tagsets.rtf startpage = now;"

 

However, replacing my ods rtf with ods tagsets.rtf (and perhaps having to switch from "startpage = NEVER" to "startpage = NO") has caused numerous problems:

 

1) Failure of the text appearing after "ods tagsets.rtf text=" to naturally break across pages if the text doesn't fit on the page (it starts a new page even though I specify "ods tagsets.rtf startpage= NO" immediately prior to that code.)

 

2) a page break appears between each of multiple successive "ods tagsets.rtf text=" even though I specify "ods tagsets.rtf startpage= NO" in between each. (I will need to use a separate one for each paragraph of text I want to insert because I believe the character limit of each text string able to be inserted is only 4000, and the narrative text will easily exceed that.)

 

3) null values for my Page ^{pageof} (which previously populated)

 

4) failure of the footnotes to align to the bottom of the page (which was previously aligned) 

 

5) the mysterious appearance of the undesired text "(Continued)". 

 

6) and I will need to apply a font_style and font_size to the text and I do not yet know how to do that.

 

Thanks,

Carol

 

 

 

Cynthia_sas
SAS Super FREQ
Hi:
Some of these are issues you're going to want to raise with Tech Support. I believe the Page X of Y may only appear when you do PRINT preview, but since the titles and footnotes are not put into the header section of the document, it's also possible that your Page X of Y page numbering won't work.

You can use ODS ESCAPECHAR style overrides to impact some of the text you place with ODS TEXT -- I believe that font style and font size may work with ODS ESCAPECHAR and style functions; but I believe that for some style changes, you may need to alter the style template.

The behavior with the footnotes is part of how TAGSETS.RTF differs from original RTF -- the footnote does NOT go into the document footer section (like it does with ODS RTF). So if you want most of your capabilities, you may just need to stick with ODS RTF and live with the ODS TEXT being in a table.

Cynthia
CarolV
Fluorite | Level 6

Thank you Cynthia. It seems there is no satisfactory solution for this. We will continue to use ods rtf for now for all the added features we need that the tagsets solution does not provide. For now we will simply manually perform the last step of converting cell contents to text. In the future we will look to a non-SAS solution. Thanks again.

mtnbikerjoshua
Obsidian | Level 7

For those finding this topic in the future, the new ODS WORD destination (currently in preproduction) does not have the same behavior of inserting text as a table cell. Using proc odstext to the word destination produces plain text not inside a table cell. If a word document is your end destination, this might be a good option.

Ksharp
Super User
/*
Here is one thing you could try.
Try using PRETEXT= style instead.
*/
proc template;
 define style styles._journal;
  parent=styles.journal;
   style table from output / cellpadding=0 just=l;
 end;
run;



ods rtf file="c:\temp\report.rtf" style=_journal   ; 
title;
proc report data=sashelp.class nowd  
style={ pretext="Twas brillig and the slithy toves did gyre and gimble in the wabe."} 
;
run;
ods rtf close;

Ksharp_0-1679398972719.png

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 14 replies
  • 7220 views
  • 2 likes
  • 5 in conversation