2
votes

I have PNG files that were created outside of SAS that I would like to include in an RTF file that I will output from SAS using ODS. Is it possible to use SAS to do this? My internet searches are turning up a lot of irrelevant results.

1

1 Answers

2
votes

ODS RTF: The Basics And Beyond, is certainly relevant. Here's an example of doing this in body text not using the title.

ods rtf file="c:\temp\test.rtf" startpage=never;
ods escapechar='^';
proc print data=sashelp.class;
run;
ods text='^S={preimage="C:\temp\SGPlot.jpeg" just=c}';
proc print data=sashelp.class;
run;
ods rtf close;

That's using a random SGPLOT I had laying around, but of course you can use whatever you prefer. I added startpage=never to have it put things on the same page - but of course that's optional (otherwise it'll put the image on its own page in my example).

The important thing is the ods text (which puts some text, normally), the ods escapechar (which sets ^ to be the escape character), and then ^S={ } which is how you insert styles and similar things in RTF (and other destinations). Then we just use preimage which means put an image before the next bit (the text, which is blank here). You could just as easily have put this in the title statement, rather than ods text, if that's where you want the image.