The SAS Output Delivery System and reporting techniques

Images in a table

Reply
Occasional Contributor
Posts: 6

Images in a table

Hello - I am creating a report using ODS RTF. I want to report frequencies of particular images. It would be helpful to actually have the image in the table instead of just the description "woman with birthday cake". I have the urls for each image. Is there a way to do this?

Grand Advisor
Posts: 9,699

Re: Images in a table

Which procedure(s) are you using and where do you want the image to appear?

Occasional Contributor
Posts: 6

Re: Images in a table

I want the image to appear in the table. I can use whatever procedure works easiest - either proc tabulate or proc report, I suppose. I have seen how to do it in proc report with images saved in a particular location. However, I want to do it using the urls because it will save me work and also save me from  having to change my code or save more files if the database I'm using gets updated. 46552 - Embed images in a PROC REPORT table

I want a table that shows the image and the frequency of the use of the image, for posters, flyers, etc. So one column would be the image, the other columns would be Posters, Flyers, etc. and the number in those columns would be the frequency. Does that make sense?

Occasional Contributor
Posts: 6

Re: Images in a table

So, I have tried it with modifying the code from the above note 46552.

However, I get an error:

ERROR: A component of

       C:\Users\scb234\http:\\URL is not a directory.

ERROR: Unable to load image C:\Users\scb234\http:\\URL

I do not have C:\users\scb234 in my format dataset, so I do not understand why it is putting it in there?

Grand Advisor
Posts: 9,699

Re: Images in a table

Show the code for your format dataset. You may have used an option around filenames that sometimes will prefix with the current directory active in SAS.

Occasional Contributor
Posts: 6

Re: Images in a table

data fmt;

     set image3;

     fmtname="mypic";

     start=image_id;

     label=url;

     keep start fmtname label;

run;
proc format cntlin=fmt;

run;

I don't think I used any options. If so, how do I turn it off? I also realize that it works in ODS HTML, but not in ODS RTF.

SAS Super FREQ
Posts: 8,642

Re: Images in a table

Hi, I always recommend that you should start with a simple example. They used a format step to assign the image location and I prefer a more straightforward way as "proof of concept". I do not have the kind of data you describe, so I just took 2 rows from SASHELP.CLASS and used some clipart to make images. See screen shots and code below.
     

The trick when you make RTF output with images, is that the location of the image for RTF (and PDF) must be the place where the image lives when the RTF (or PDF) file is CREATED. Note that my images live in the same physical directory where the RTF file will be created. This is because RTF takes any image you "feed" it and translates that image into internal RTF form, effective embedding the image inside the RTF file. It almost looks to me like you tried to get an image off the web using a URL and I don't think that this will work. That would be a question for Tech Support.
    

Cynthia

ods listing close;

ods rtf file='c:\temp\sample.rtf';

title 'Embed Images in PROC REPORT Column';

proc report data=sashelp.class nowd

   style(column)={vjust=m font_weight=bold font_size=12pt};

   where name in ('Alice', 'William');

   column name sex height weight image;

   define name / display;

   define image / computed style(column)={width=2.5in};

   compute image;

     length imageloc $120;

     image = ' ';

     if name = 'Alice' then do;

       imageloc = catt('style={preimage="c:\temp\Alice.jpg"}');

     end;

     else if name = 'William' then do;

       imageloc=catt('style={preimage="c:\temp\William.jpg"}');

     end;

    call define(_col_,'style',imageloc);

   endcomp;

run;

    

ods _all_ close;

Attachment
Attachment
Attachment
Occasional Contributor
Posts: 6

Re: Images in a table

Yes, I am getting the images from the web since that is where they are stored. It works if I use ods html, but I get the error with the rtf output. I think there must be something with the options/settings that is going wrong. I would prefer to be able to use the rtf as the output instead.

SAS Super FREQ
Posts: 8,642

Re: Images in a table

Hi:

  This Tech Support note implies that a URL will work: 24488 - Can I use a relative path to point to an image I want to place in an ODS PDF or ODS RTF file... However, this note only shows a physical drive location for the image 24047 - In ODS RTF, how can I add images to my output file?
    

  And, when I try a URL, I am not able to get the image into the RTF file. I believe this is something that you should work on with Tech Support. They can determine which note is correct and whether the URL method of referencing a file should work or not. To me, it looks like my default working directory path is being "prepended" to the value in the PREIMAGE= option. And, of course, that is an incorrect location.
   

cynthia

Attachment
Post a Question
Discussion Stats
  • 8 replies
  • 735 views
  • 0 likes
  • 3 in conversation