A watermark attribute does exist. But, it only works for the HTML destination (not RTF). In ODS HTML, the watermark attribute allows you to "specify whether or not to make the image that is specified by BACKGROUNDIMAGE= into a "watermark." A watermark appears in a fixed position as the window is scrolled." (this description is straight from the documentation.) The value for WATERMARK is either ON or OFF (because it works in conjunction with BACKGROUNDIMAGE).
However, there is one thing you can try. Since Microsoft Word can read an HTML file, you could create an HTML file using BACKGROUNDIMAGE and WATERMARK (as shown below) and then open the HTML file with Microsoft Word. Once it's in Word, you can either save it as a .DOC file or save it as an RTF file. The image will be tiled in the browser and will also be tiled when Word opens it. Therefore, you should try to make the image very close in size to what you want the watermark to be in order to minimize tiling.
Here's the sample code...where I have kermit.jpg specified below, you would insert the name of your image file to be the watermark. You need the change to the style template because the table (in this case, from PROC REPORT), sits on the BODY of the HTML document. Therefore, you want to modify the BACKGROUNDIMAGE for the BODY of the document.
ods path work.wmark(update)
define style styles.water;
style body from body /
proc report data=sashelp.class nowd;
column name age height;
ods msoffice2k close;
I do not know whether there's a way using RTF control strings to specify a watermark.
In the Microsoft Word help (I start there because Microsoft wrote the RTF specification) -- it says that watermarks are intended for a PRINTED document. MS Word help says:
"On the Format menu, point to Background, and then click Printed Watermark"
If I follow those instructions and insert a picture to be used as a watermark AND then save the file as an RTF file, it looks to me like my picture has been converted to RTF format and is inserted with a \pict control string. However, \pict does NOT point to my original picture...it is followed by the RTF graphics version of the picture. According to the RTF 1.5 spec, which I found here,
"An RTF file can include pictures created with other applications. These pictures can be in hexadecimal (the default) or binary format. Pictures are destinations, and begin with the \pict control word. The \pict keyword is preceded by \*\shppict destination control keyword as described in the following example."
So if you can live with creating an HTML file and then instructing folks to open the HTML file with Word, this may be a solution that works for you. If you need to generate an RTF file with a watermark, then I do not believe that ODS can help you right now. I do not know whether future plans for RTF (or some other MS Word Markup Language) include plans for Watermark support.
Currently, there is no watermark support in the RTF files created by SAS.
The 1.6 RTF Specification supported by MS Word does not mention watermarks. But, you can apply a watermerk using the Format pulldown in Word and selecting "Background". You can follow the arrows from that point and all is good.
You can even save the DOC file as RTF and have the watermark preserved. When you re-open the RTF file, the watermark remains.
This is done by combination of techniques. Word embeds the image a hex translation with a \pict syntax, but makes it a a shape object with specific characteristics. It is placed in various parts of the section information and makes use of stored name and value pairs to pass information back to Word. The stored name/value pairs are part of Visual Basic.
The 1.6 RTF spec is careful about supporting older syntax in newer versions. We prefer to not support techniques we cannot be certain will be carried forward.
The best way to put a watermark on the document is currently in Word and saving as either an RTF file or DOC file. There are modifications that can be done in Word but will be lost when saved to an RTF file. This is not one of them.
I wonder if there is a way to call a VBA macro when producing some RTF. It is pretty easy to make a VBA macro in word to add a watermark. Can we tell ODS/RTF to call this macro somehow? I know we can do it from windows by opening word with DDE, loading the RTF and calling the macro - but is there another way?
My question would be: what happens if SAS is out of the picture.?
In other words, if you create a little file by manually typing in Word and then define a macro in that document to load the watermark. If you then save that Word file as an RTF file, do the macro instructions carry over into the RTF version or do you get that snarky message that some features in the Word doc will be lost?
Just curious. I don't -do- VBA or Word macros because I'd have to jettison something in my brain to make room for a new language.
(I suspect that you'll get the \pict image in the RTF file and not the instruction to use the macro -- but that's just speculation on my part.)
Suggest checking the SAS support website for technical and conference paper resources on ODS and calling a VBA macro. Here is a Google advanced search argument (limited to searching the SAS.COM site only) which yielded some matches: