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

Hi everyone, I'm attempting to insert images into a report I'm writing with report writing interface via URL.  A specific image needs to be in every region on a page, and the image is stored on a web server.  I use obj.image(file: myurl) and got the error unable to load image...default image will be used.   Resources on image inserting via url don't seem to be plentiful.  Any help and examples are much appreciated, and I'd also like to know if this image will be automatically sized to fit the region, and if not, how to can specify it's dimensions!

 

Thanks!

 

obj.region(
width:"1.9in", height: "3.2in",
x : "0in", y: "0in",
style_attr: "background=grey color=grey"
);

obj.image(file: 'my.com/url');

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  This example worked for me. It is a picture of Lewis Carroll available at a URL. I needed a fully qualified HTTP address for the URL.

cynthia

 

ods pdf file='c:\temp\testurl.pdf' notoc;
 
data _null_;
  length pixloc $256;
  if _n_ = 1 then do;
    pixloc='http://img.bhs4.com/45/e/45e71f0d91fb0b65b98b129552466d58c2e46d6d_large.jpg';
  end;
  if _n_ = 1 then do;
     dcl odsout obj();
     obj.layout_gridded(columns:1);
  end;
  obj.region(width:"3.25in");
  obj.image(file: pixloc ,
            overrides:"just=left width=100pct"); 
  if eof eq 1 then
    obj.layout_end();
run;
 
ods pdf close;

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  This example worked for me. It is a picture of Lewis Carroll available at a URL. I needed a fully qualified HTTP address for the URL.

cynthia

 

ods pdf file='c:\temp\testurl.pdf' notoc;
 
data _null_;
  length pixloc $256;
  if _n_ = 1 then do;
    pixloc='http://img.bhs4.com/45/e/45e71f0d91fb0b65b98b129552466d58c2e46d6d_large.jpg';
  end;
  if _n_ = 1 then do;
     dcl odsout obj();
     obj.layout_gridded(columns:1);
  end;
  obj.region(width:"3.25in");
  obj.image(file: pixloc ,
            overrides:"just=left width=100pct"); 
  if eof eq 1 then
    obj.layout_end();
run;
 
ods pdf close;
yus03590
Calcite | Level 5

I'm getting the following errors when running the code:

 

ERROR: Unable to load image
http://img.bhs4.com/45/e/45e71f0d91fb0b65b98b129552466d58c2e46d6d_large.jpg;

default image will be used instead.

 

The log file also has the following warning:

WARNING: ODS Report Writing Interface is not supported for TAGSETS.SASREPORT13(EGSR) destination.  Results may be unpredictable.

 

However I've used RWI to generate reports on this machine/server before (Never with images though).

 

Any insights?

 

Cynthia_sas
SAS Super FREQ
Hi, It looks like you're using Enterprise Guide. In my sample code, I was NOT using EG and I was controlling my ODS Destination with programming statements.

My suggestion is that you put an
ODS _ALL_ CLOSE;
before the ODS PDF statement and make sure that your FILE= option is pointing to a location where you have WRITE access. Also, harder to check is that you will need to make sure your program, which is running on a server, can access a URL from the server machine. If your web folks have locked down the server so it cannot use an HTTP address, then you will have to move your images to an accessible location on the server. You may need an administrator's help with that.

My image was just a picture of Lewis Carroll that I found and used because it had a direct HTTP address. If you have your images on a network drive, then perhaps a simple folder path will work for you.

cynthia

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