BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I need to insert an image into the table of the PROC REPORT (in the
box upper left of the table).
With the proc tabulate it works and the syntax is


PROC TABULATE data=....;
VAR ...;
CLASS ....
/ BOX={STYLE={preimage="image.bmp"}};
RUN;


But with the proc report, after many attempts, I was able to insert
the image only before the table as you can try with the code below.
Any idea?
Thanks in advance
Matteo

data example;
analisys=100;second=1000;third='ex1';number=100;output;
analisys=200;second=2000;third='ex1';number=200;output;
analisys=300;second=1000;third='ex2';number=300;output;
analisys=400;second=2000;third='ex2';number=400;output;
run;


proc report data=example missing nowindows
style(report)={preimage="image..bmp"};;


column third second,( analisys number);
define third / group 'third';
define second / display across 'second';
define analisys /analysis '' ;
define number / analysis '';


rbreak after / summarize; run;
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi...you CAN make the preimage part of the style for the label for that upper cell...but it would actually be placed on top of any text you have in that cell. So, for example, let's say you have a picture of Kermit the Frog, located at: c:\temp\kermit.jpg

Here are a couple of examples you could use to put that image into a header cell above the text 'third':
[pre]
ods listing close;
ods html path='c:\temp' (url=none)
file='kermie.html' style=sasweb;

ods escapechar='^';

proc report data=example missing nowindows;
title 'one way';
column ('^S={preimage="c:\temp\kermit.jpg"}^nthird' third) ('Second' second,( analisys number));
define third / group ' ' ;
define second / display across ' '
style(header)={vjust=b};
define analisys /analysis ' ' ;
define number / analysis ' ';
rbreak after / summarize;
run;

proc report data=example missing nowindows;
title 'another way';
column third second,( analisys number);
define third / group '^S={preimage="c:\temp\kermit.jpg"}^nthird';
define second / display across 'second';
define analisys /analysis ' ' ;
define number / analysis ' ';
rbreak after / summarize;
run;
ods html close;
[/pre]

Proc Report does not have a away to directly address the box at the very upper left hand corner (this box occurs when you have multiple and sometimes spanning headers above the columns that have the side effect of creating an empty box that looks exactly like the TABULATE box, but isn't at all like the TABULATE BOX area.

This example uses ODS ESCAPECHAR to put a style attribute in a very specific place -- above the label for the "third" column. The style attribute is the preimage attribute and it is going to carry the information for the picture.
Have fun!
cynthia
deleted_user
Not applicable
Hi Cynthia,
I tried with your two examples but in both cases I have the two reports WITHOUT the image and no error log.
Do you have idea where is the problem?
Thanks in advance
Matteo
Cynthia_sas
SAS Super FREQ
Hi, Matteo:
Well...hmmm....
1) when I have my picture stored in c:\temp\kermit.jpg
AND
2) I use c:\temp\kermit.jpg in the preimage
I do get the image in my HTML output file.

If you are using RTF or PDF as the ODS destination, you might not see the image because the image is translated from the original form to an internal form used by PDF and RTF. Therefore, the image location must be the place where ODS will find the image when the output file is CREATED. On the other hand, the image location for HTML must be the location where the output file and image file will be when the output file is RENDERED.

So if, for example, you kept the image in C:\temp and subsequently moved the HTML file to a web server -- without moving the image -- then you would not see the image. In addition, if the ultimate location of the image is a web server for example AND the image may be stored in a sub-directory on the web server, then you might need to change the preimage attribute to something like this:

preimage="http://www.sesame.com/dir/subdir/kermit.jpg"

At this point, here are some things you can do:
1) double check your version of SAS. ODS ESCAPECHAR was first introduced in SAS 8.2 (I think) so if you are running an older version of SAS, I would not expect this example to work.
2) double check your image -- make sure that you have the right location and the right spelling for the image file
3) double check your syntax -- make sure that you DO have an ODS ESCAPECHAR statement:
ODS ESCAPECHAR='^'; AND
4)double check that the character used in the ODS ESCAPECHAR statement is the same as the one used in your style= override with escapechar=
'^S={preimage="c:\temp\kermit.jpg"}^nthird'

Note in the example above that the word third is my label string. And also note that the attribute preimage="c:\temp\kermit.jpg" is in double quotes. That means my WHOLE string -- the one with ESCAPECHAR ^S= AND the preimage override AND the label text must be enclosed in single quotes or vice versa.

and 5) double check the image itself and make sure that you can open the image file in a browser window or with a paint program (without SAS being involved) to ensure that the image -is- there and is a good, usable image.

The ESCAPECHAR control string will NOT be used by the LISTING destination, but SHOULD be used in destinations that support style overrides....so the whole string that I am using, in my example, is enclosed in single quotes and the preimage text is enclosed in double quotes within the single quotes.

Also, if you are using macro variables, I suggest you get the program working WITHOUT macro variables or macro quoting issues involved.

If you are running SAS 8.2 or higher and if you have checked your syntax and quoting and picture, then I think your best bet for further help is to contact SAS Technical Support:
http://support.sas.com/techsup/contact/index.html

Good luck!
cynthia
deleted_user
Not applicable
Cynthia,
in the results of your examples I don't have the label "third" but the label "nthird".
This means that my version (8.2) doesn't recognize the escapechar?
I think I'll contact the support....

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