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

I am trying to add an image to an HTML table from a report email output.

The image needs to be part of the table on the first row, where the real column headers placed on the second row of the table. I am successful in placing that image on the top using PREIMAGE with the STYLE TABLE, but it is outside of the table. And I need to make it inside and part of the table.

I played with this before and had it worked. Now I forgot how I did it. It seems that I need to include a line with the STYLE HEADER.

Does anything know how to do this?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Well, you really don't need a style template to achieve what you want and although you probably could do this with a custom table template, I think that PROC REPORT will do this for you quite nicely. If you use a simple COMPUTE BEFORE _PAGE_ -- the ONLY place that ODS HTML would be able to write the PREIMAGE would be inside the border of the table but only at the very top, above all the header rows. So, I have a picture of Kermit the Frog in the file: c:\temp\kermit.jpg and if I run this simple ODS HTML step, which writes my HTML output also to c:\temp, using ONLY PROC REPORT (no custom style, no custom table), when I open the resulting HTML file, I see the picture of Kermit inside the border of the table.

cynthia

ods html path='c:\temp' (url=none) file='usepix.html'

         style=sasweb;

   

proc report data=sashelp.class(obs=3) nowd;

  compute before _page_ /

          style={preimage='kermit.jpg'};

    line ' ';

  endcomp;

run;

   

ods html close;

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  What is your procedure of choice??? For example, if you were using PROC TABULATE, you could add a style override to the BOX= option in order to put an image into the TABULATE box area. If, on the other hand, you were using PROC REPORT, you could put the image into the header by putting the PREIMAGE attribute as part of the header instruction for the first item in your column statement. Or, alternately, you could use a COMPUTE BEFORE _PAGE_ to insert the image at the very top of the table.

  I would not add the PREIMAGE attribute to a style template, in the instance where you only want the image in 1 place on your output table.Without knowing your procedure of choice (for example, with PROC MEANS or PROC FREQ, you'd have to either change the TABLE template or create and output dataset and then use PROC PRINT or REPORT) ... it's hard to figure out what's the best approach.

cynthia

JRD
Calcite | Level 5 JRD
Calcite | Level 5

Thanks, Cynthia,

I use PROC TEMPLATE and PROC REPORT for this.

I define the table structure in PROC TEMPLATE, and I am indeed trying to add the image using PREIMAGE to the header. It places the image with each column header (so the images appear along with  the column labels multiple times), but the the result is not what I wanted. I want the single image to appear on top of the column header as a separate row.

For example, for a 4X10 table, the image will appear on top of this 4X10 table, but it is framed and still inside the table as a separate row as a banner to this 4X10 table. I hope this is not too confusing? As I mentioned, I did have it work, but I simply don't remember how I did it, but using something like BEFORE does sound familiar, but not sure exactly how.

Thanks.

Cynthia_sas
SAS Super FREQ

Hi:

  Well, you really don't need a style template to achieve what you want and although you probably could do this with a custom table template, I think that PROC REPORT will do this for you quite nicely. If you use a simple COMPUTE BEFORE _PAGE_ -- the ONLY place that ODS HTML would be able to write the PREIMAGE would be inside the border of the table but only at the very top, above all the header rows. So, I have a picture of Kermit the Frog in the file: c:\temp\kermit.jpg and if I run this simple ODS HTML step, which writes my HTML output also to c:\temp, using ONLY PROC REPORT (no custom style, no custom table), when I open the resulting HTML file, I see the picture of Kermit inside the border of the table.

cynthia

ods html path='c:\temp' (url=none) file='usepix.html'

         style=sasweb;

   

proc report data=sashelp.class(obs=3) nowd;

  compute before _page_ /

          style={preimage='kermit.jpg'};

    line ' ';

  endcomp;

run;

   

ods html close;

JRD
Calcite | Level 5 JRD
Calcite | Level 5

This works!!!

Thank you, Cynthia!!!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1905 views
  • 0 likes
  • 2 in conversation