Simulatenous ODS HTML and RTF

Reply
Contributor
Posts: 60

Simulatenous ODS HTML and RTF

Hi,

I was wondering if it is anyhow possible to run my code into two different ODS destinations with slight differencies on the outputs depending on the destination?

For example I would like to output the same text on both destinations, but on RTF I would need to add tags like:

^\tc ^\b ^\tcl1 etc. (^ is my ods escapechar) which html on the other hand won't handle.

Now I have "solved" the problem running the code 2 times and using macro variables to inform the program if it is HTML or RTF destination that I am using.

However this is time consuming and resource wasting method and would be more than happy to get this done in one single run.

So in short I would like to know if SAS generates automatically somekind of identifications to which destination it is streaming at which point so I could use IF clauses or something similar to control these slight differencies.

Thanks.

Super User
Super User
Posts: 7,695

Re: Simulatenous ODS HTML and RTF

Hi,

The ods tagsets system wouldn't have conditional for embedded specials like that.  You can easily output to two different destinations just by opening them but you code would need to work out what goes to where.  So I see three ways of doing it:

1) Create a macro with conditional branching to do this.  My least favourite.

2) Pre-process your data to contain the relevant information e.g.:

data html_output rtf_output;

     set data;

     output html;  /* This just copies the row to html_output destination */

     row=strip(row)||'^\tc';  /* Example adding a code;

     output rtf;

run;

ods html ...;

proc print data=html_output;...

ods close;

ods rtf ...;

proc print data=rtf_output...

3) Generate your code on the fly with call execute:

data _null_;

     set data;

     call execute('ods html...';

                          proc print data=data...;

                          data data;

                                   set data;

                                   row=strip(row)||"^\tc";

                          run;

                            ods rtf file=...');

run;

Respected Advisor
Posts: 3,786

Re: Simulatenous ODS HTML and RTF

Look at this INSERTING RAW TEXT USING ODS ESCAPECHAR CONTROL STRINGS in this paper by .

Contributor
Posts: 60

Re: Simulatenous ODS HTML and RTF


I was able to do almost everything with RW9's help but... I would need to get header and footer for the rtf but not for the html output and that seems to be impossible. Any help is much appreciated.

Edit: I came with an idea that I could "update" the rtf file to contain the header and footer after the code has run on both destinations. But I don't know if that is even possible?

Valued Guide
Posts: 3,208

Re: Simulatenous ODS HTML and RTF

It seems that SAS(R) 9.4 Output Delivery System: Procedures Guide  proc document is intended for that purpose...

---->-- ja karman --<-----
Contributor
Posts: 60

Re: Simulatenous ODS HTML and RTF


Thanks I am pretty sure this is what I need. However I have troublesome times with the footnote and headers still.

Do you know how to set "global" header and footer in the proc document. Here is the code I use at the moment:

ods document name=test;

.

.

.

ods document close;

ods html;

proc document name=test;

replay;

run;

quit;

ods html close;

ods rtf;

proc document name=test;

replay;

run;

quit;

ods rtf close;

and would like to add these global statements to the rtf output title1,title2 and footer1 (repeated on every page).

However I was unable to do this. When I used the list statement in the proc document it did not list any attributes(I don't know if the footer and header are called that), but only the tables I created in the ods document block.

Edit: I have included a sample code with the tried solutions for the problem (you have to update the rtf file url to get it work)

Attachment
Ask a Question
Discussion stats
  • 5 replies
  • 233 views
  • 6 likes
  • 4 in conversation