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?
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:
Hope this helps,
Cynthia
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
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".
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.
@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.
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;
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.>
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:
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
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
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.
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.
/*
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;
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.