BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gyambqt
Obsidian | Level 7

Hello Experts,

I want to know if there is way to insert image when you use ODS tagset EXCELXP.

I think tagset excelxp will generate xml file which can not incorporate any graph or images and wondering if there is any alterative way to insert image in excel in addition to the table produced. like ods msoffice2k...but not sure how to achieve the result.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  By Microsoft design, the type of XML that is produced by TAGSETS.EXCELXP does NOT support the inclusion of images. The XML spec is for Excel 2003 and there is no way to put images into the file unless you create the XML file with SAS, open and save the file as an XLSX file or XLS file and then, after you have saved the file to a proprietary Excel format, you can include your image.
         

  The alternative to this, as you noted is ODS MSOFFICE2K (which makes an HTML file) or ODS MSOFFICE2K_X (which makes an HTML file with some XML embedded). Since HTML supports image insertion, you do have the ability to use images with these HTML files. But you are really "inserting" an image into HTML. An HTML file uses an <IMG> tag to point to the external location of the image. And that doesn't change if you use either of these 2 destinations. If you are familiar with the basic "sandwich" technique of ODS, then you use the same technique with either of these destinations. Instead of:

ods tagsets.excelxp file='c:\temp\myreport1.xml';

... sas code ...

ods tagsets.excelxp close;

 

You would have something like:

ods msoffice2k file='c:\temp\myreport2.xls';

... sas code ...

ods msoffice2k close;

 

ods tagsets.msoffice2k_x file='c:\temp\myreport3.xls';

... sas code ...

ods tagsets.msoffice2k_x close;


Do note that both of the above files are really HTML files. Naming them as .XLS just fools the Windows registry into launching Excel when you click on the file instead of launching a browser.

   

Or if you have SAS 9.4, you can try the new ODS EXCEL destination, as described here: http://blogs.sas.com/content/sasdummy/2014/08/29/experimenting-with-ods-excel-to-create-spreadsheets... in which Chris Hemedinger shows how to insert an histogram into an Excel worksheet created with the new ODS EXCEL destination.
       

cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  By Microsoft design, the type of XML that is produced by TAGSETS.EXCELXP does NOT support the inclusion of images. The XML spec is for Excel 2003 and there is no way to put images into the file unless you create the XML file with SAS, open and save the file as an XLSX file or XLS file and then, after you have saved the file to a proprietary Excel format, you can include your image.
         

  The alternative to this, as you noted is ODS MSOFFICE2K (which makes an HTML file) or ODS MSOFFICE2K_X (which makes an HTML file with some XML embedded). Since HTML supports image insertion, you do have the ability to use images with these HTML files. But you are really "inserting" an image into HTML. An HTML file uses an <IMG> tag to point to the external location of the image. And that doesn't change if you use either of these 2 destinations. If you are familiar with the basic "sandwich" technique of ODS, then you use the same technique with either of these destinations. Instead of:

ods tagsets.excelxp file='c:\temp\myreport1.xml';

... sas code ...

ods tagsets.excelxp close;

 

You would have something like:

ods msoffice2k file='c:\temp\myreport2.xls';

... sas code ...

ods msoffice2k close;

 

ods tagsets.msoffice2k_x file='c:\temp\myreport3.xls';

... sas code ...

ods tagsets.msoffice2k_x close;


Do note that both of the above files are really HTML files. Naming them as .XLS just fools the Windows registry into launching Excel when you click on the file instead of launching a browser.

   

Or if you have SAS 9.4, you can try the new ODS EXCEL destination, as described here: http://blogs.sas.com/content/sasdummy/2014/08/29/experimenting-with-ods-excel-to-create-spreadsheets... in which Chris Hemedinger shows how to insert an histogram into an Excel worksheet created with the new ODS EXCEL destination.
       

cynthia

gyambqt
Obsidian | Level 7

Thanks a lot! very very useful.

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
  • 2997 views
  • 1 like
  • 2 in conversation