BookmarkSubscribeRSS Feed
LeeJenson
Calcite | Level 5
Hi,

I am using the following code to include an image in my .xls. I am using ODS HTML to control cell colours but this code inserts a link I think? Is it possible to include an image inside the excel spread and it NOT just be a link to an image?

proc report data= xxx nowd split='\' headline headskip
style(Report)=[preimage="xxx.jpg" vjust=top] nowindows ;
columns label header;
define label / display '';
define header / display '';
title ' test title';
run;

Thanks
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
When you call your file "an .xls", then I imagine you have done this:
[pre]
ods html file='myfile.xls';
[/pre]

When you use ODS HTML to create an ASCII text file, the information in the file is in HTML format -- your information from SAS is delimited by HTML tags (like <TABLE> and <TD> tags). Excel has been able to open HTML files ever since Office 97, however, Excel is only reading the HTML tags and rendering the HTML table (including images) into spreadsheet form.

Naming your file .XLS does not make the file a true, binary Excel file, in Microsoft proprietary format. It merely "fools" the Windows Registry into launching when the file is clicked --or makes Excel the default application to open the file. If you look at your ODS HTML file with Notepad, you will still see HTML tags inside the file.

As an HTML file, the correct way to point to images is with an <IMG> tag. Therefore, when you use the PREIMAGE style attribute, ODS builds an <IMG> tag. I believe that if you save your HTML file with an image as a proprietary Excel file (Excel 97-2003 xls), that the image will be converted to "internal" Excel format. You might be able to automate this process of saving the HTML file to proprietary format with an Excel macro or VBA script.

If you use the ODS RTF or ODS PDF destinations, then your image is converted to internal RTF or PDF format, when the file is created and the image is essentially embeddeded into either of those output files.

cynthia

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2125 views
  • 0 likes
  • 2 in conversation