The SAS Output Delivery System and reporting techniques

add image to top of and inside the table

Accepted Solution Solved
Reply
Occasional Contributor JRD
Occasional Contributor
Posts: 7
Accepted Solution

add image to top of and inside the table

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.


Accepted Solutions
Solution
‎06-30-2011 03:26 PM
SAS Super FREQ
Posts: 8,745

Re: add image to top of and inside the table

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


All Replies
SAS Super FREQ
Posts: 8,745

add image to top of and inside the table

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

Occasional Contributor JRD
Occasional Contributor
Posts: 7

add image to top of and inside the table

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.

Solution
‎06-30-2011 03:26 PM
SAS Super FREQ
Posts: 8,745

Re: add image to top of and inside the table

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;

Occasional Contributor JRD
Occasional Contributor
Posts: 7

Re: add image to top of and inside the table

This works!!!

Thank you, Cynthia!!!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 287 views
  • 0 likes
  • 2 in conversation