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
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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