BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

In general, how to put a table and a external picture which not made by SAS/Graph (size = 6.4 in * 4.6 in ) into a same html using SAS. I search online and most papers are related to use ods layout or htmlpanel to layout a table and a graph which made SAS/graph together.



I try to insert a graph under a table but graph does not display when I use proc REPORT (such as preimage postimage)

ods html file = "H:/Temp/mytest.html";

proc report data = mydata;
column id x y;
define id;
define x;
define y;
compute after _page_ / center;
call define
(_ROW_,"style",'style=[POSTIMAGE="h:\Temp\en_5.gif"]');
endcomp;
run;

Thanks,
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
I would have expected you to receive an ERROR on your DEFINE statement. Something like:
[pre]
define id;
-
22
76
6 define x;
-
22
76
7 define y;
-
22
76
ERROR 22-322: Syntax error, expecting one of the following: -, /, :.
ERROR 76-322: Syntax error, statement will be ignored.
[/pre]
...because the PROC REPORT syntax requires a slash and at least one other DEFINE statement option for the variable.

However, putting aside that issue, this code works for me (I have a picture of Kermit the Frog in my c:\temp directory):
[pre]
ods listing close;
ods html path='c:\temp' (url=none)
file = "mytest.html" style=sasweb;

proc report data = sashelp.class(obs=3) nowd;
column name age height;
define name / display;
define age / display;
define height /display;
compute after /
style=[POSTIMAGE="kermit2.jpg"];
** write a blank so it can have a postimage;
line ' ';
endcomp;
run;
ods html close;
[/pre]

It is really not appropriate to use CALL DEFINE with _ROW_ for a COMPUTE AFTER. Also, since HTML has not concept of PAGES, a simple COMPUTE AFTER will work as well as COMPUTE AFTER _PAGE_. In this instance, all you need is a LINE statement with 1 blank and then the POSTIMAGE attribute on the COMPUTE statement itself will serve to put the image under the last row of the tabular output (but inside the "box" of the table).

If you want the image to be underneath the table, but not inside the "box" of the table, then you can use your POSTIMAGE attribute in a FOOTNOTE statement. Something like this:
[pre]
ods listing close;
ods html path='c:\temp' (url=none)
file = "mytest2.html" style=sasweb;
ods escapechar='^';

proc report data = sashelp.class(obs=3) nowd;
column name age height;
define name / display;
define age / display;
define height /display;
footnote '^S={POSTIMAGE="kermit2.jpg"} ';
run;
ods html close;
title; footnote;

[/pre]

This should get you on the right track. There are many previous forums postings on the use of ODS ESCAPECHAR.

cynthia
deleted_user
Not applicable
Hi Cynathia,

Thank you for replying my problem.

I run your codes and change a link to my picture but I still got a red “X” instead of a graph.

Would you please help me on it? I used SAS9.2 phase 2.

title;

ods listing close;

ods html path='h:\Temp' (url=none)

gpath='h:\Temp'

file = "mytest2.html" style=sasweb;

ods escapechar='^';


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

column name age height;

define name / display;

define age / display;

define height /display;

footnote '^S={POSTIMAGE="en_5.jpg"} ';

run;

ods html close;

footnote;
Cynthia_sas
SAS Super FREQ
Hi:
At this point, the only things to check are:
1) make sure that the name of the image file is correct, that the name is not case-sensitive (as it might be on a Unix file system), and that you can navigate to H:\Temp and find the file en_5.jpg.

2) make sure that the file extension is correct .JPG and not .JPEG or .JFIF or .GIF or any other image file extension

3) make sure that you have the proper access to READ the file from the h:\Temp directory

4) clear your temporary Internet cache and then rerun the program using a different HTML file name (a file that has not ever been cached on your system)

Otherwise, if none of these fix the problem (my money is on the case-sensitivity of the image file name or on access privileges), then you may need to open a track with Tech Support. (When I run your code and change the location to c:\temp, I get an image where I expect to see an image...even though GPATH is not needed in this job because we are not using any SAS/GRAPH code to make an image.)

To open a track with Tech Support, go to:
http://support.sas.com/ctx/supportform/createForm

cynthia
Flip
Fluorite | Level 6
My guess at this is that the path to the picture is correct for the SAS program, but not for the URL in the browser. The picture is not imbedded, only a link to the location, which the browser must be able to find.
Cynthia_sas
SAS Super FREQ
Excellent point! There was no mention of a web server being involved. The syntax I showed builds a -relative- URL SRC= for the <IMG> tag. As long as the HTML file and the image are then moved to the same location on the web server directory structure, the relative reference should work. If the files are moved to separate directories on the web server (as might happen when the web folks store all images in a separate image directory), then the footnote statement might need to be modified:
[pre]
footnote '^S={POSTIMAGE="http://srv_dir/subdir/images/en_5.jpg"} ';
OR
footnote '^S={POSTIMAGE="/images/en_5.jpg"} ';
[/pre]

In this instance, the image might NOT be viewable on a local machine, if it was not attached to or able to load the image file. But the image would then be viewable when the HTML page was served by a web server.

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
  • 5 replies
  • 2397 views
  • 0 likes
  • 3 in conversation