BookmarkSubscribeRSS Feed
scb234
Calcite | Level 5

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?

12 REPLIES 12
ballardw
Super User

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

scb234
Calcite | Level 5

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?

scb234
Calcite | Level 5

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?

ballardw
Super User

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.

scb234
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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;


Alice.jpgwilliam.jpgembed_image_rtf.png
scb234
Calcite | Level 5

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.

Cynthia_sas
SAS Super FREQ

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


RTF_with_URL_error.png
anil2
Fluorite | Level 6

Hi  @Cynthia_sas is there any way i Can  change photo on runtime or dropdown selection or name search .

suppose i have 5 name in drop down list when i select any name from drop down list that person image  should be display in report dashboard  want to show image of higher management   as well as his profile summary in sas va report.

 

Thanks ,

Anil Patil

Cynthia_sas
SAS Super FREQ

Hi:

  I see that you posted this new question to the VA Forum: https://communities.sas.com/t5/SAS-Visual-Analytics/bd-p/sas_va and that is probably a better place for the question -- or working with Tech Support. I don't teach the VA classes, so I don't have expertise in this area.

 

Cynthia

anil2
Fluorite | Level 6

Thanks for reply @Cynthia_sas,

 

I have raised track also to sas support for same, just let me know can we insert image in sas dataset .

 

Thanks,

Anil Patil

Cynthia_sas
SAS Super FREQ
Hi:
There's a difference between inserting an image in a SAS dataset and inserting a LINK or pointer to the image in a SAS dataset vs actually inserting an image in a report. You'll need to make it clear to Tech Support which you want.
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
  • 12 replies
  • 3896 views
  • 0 likes
  • 4 in conversation