08-13-2014 06:15 AM
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.
08-13-2014 06:26 AM
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;
output html; /* This just copies the row to html_output destination */
row=strip(row)||'^\tc'; /* Example adding a code;
ods html ...;
proc print data=html_output;...
ods rtf ...;
proc print data=rtf_output...
3) Generate your code on the fly with call execute:
call execute('ods html...';
proc print data=data...;
ods rtf file=...');
08-21-2014 07:48 AM
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?
08-25-2014 04:05 AM
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;
proc document name=test;
ods html close;
proc document name=test;
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)