Hi,
in order to migrate a report in pdf from sas 9.2 to sas 9.4, I found some problems with a proc report that use an image as column
This is an example:
ods pdf file='filepdf.pdf';
ods html file='filehtml.htm';
proc report data=sashelp.class nowd spanrows style(report)={rules=none frame=void }
style(column)={font_face=arial font_size=6pt vjust=center height=0.2in} ;
column name sex age image ;
define name / 'Name ' group order=data style(column)={ cellwidth=1.2in};
define age / analysis 'Age' ;
define sex / group noprint '' ;
define image / 'Sex' computed center;
compute image /char;
if _c2_='F' then do;
call define(_col_,'style', 'style=[postimage="blue.jpg"]');
end;
else do;
call define(_col_,'style', 'style=[postimage="red.jpg" ]');
end;
endcomp;
run;
ods pdf close;
ods html close;
For the html file, the code works fine, I have a table with an image for each row.
For the pdf file instead I have only an image above the table.
In sas 9.2 I didn't have any pproblem for both the destinations.
Any idea?
Thanks a lot for your help.
Grazia
Will it generate the PDF correctly with the HTML destination closed?
Hi Ballardw,
It gives the same error, the first time I run the code it was to refresh a pdf report created with sas 9.2.
The report is made using ods absolute layout and it's very rich, so I tried to semplify the code to reduce the complexity, and I used the html destination as double check.
HI:
Generally speaking the rule of thumb is that
--HTML: the image location for pre/post image is the location where the image will be located at the time the HTML file is loaded into the browser AFTER file creation (relative names without a path are OK here because the browser will look in the same directory as the HTML file)
--PDF: the image location for pre/post image is in the location where the image is located at the time the PDF file is CREATED or DURING file creation (as ODS is building the PDF file) (relative names generally are NOT OK here)
When I modify your code just slightly to specify the EXACT path for the image, the code works for me in HTML and in PDF. IF I only have a relative name without a path, then in SAS 9.4, the HTML uses the image (because if finds the image in the same location as the HTML when the file is rendered in the browser). But the PDF file doesn't show any image because I got this message in the log (without the c:\temp):
ERROR: Unable to load image red.jpg; default image will be used instead.
ERROR: Unable to load image blue.jpg; default image will be used instead.
But, you didn't mention an error message. I'm sure you would have mentioned if you had gotten such an error message. I did find this note, 40319 - "Unable to load image" error might be received when sending output to an ODS PRINTER (PCL/PD... but it doesn't seem to be relevant to your code. Or I found this note. 34722 - JPEG image used in ODS RTF, PDF, or HTML might generate errors That would be a question for Tech Support.
See the attached screen shot of the PDF file. It was created with the code below. All I know is that I got an error with the relative name of the file and I did not get an error with the fully qualified path for the image location. My red.jpg is a red star and my blue.jpg is a blue star. They looked bad with such a small font for name, so I increased the font size for the name.
Cynthia
ods pdf file='c:\temp\filepdf.pdf';
ods html file='c:\temp\filehtml.htm';
proc report data=sashelp.class nowd spanrows
style(report)={rules=none frame=void }
style(column)={font_face=arial font_size=12pt vjust=center} ;
column name sex age image ;
define name / 'Name ' group order=data style(column)={cellwidth=1.2in};
define sex / group noprint '' ;
define age / analysis 'Age' ;
define image / 'Sex' computed center;
compute image /char;
if sex='F' then do;
call define(_col_,'style', 'style=[postimage="c:\temp\blue.jpg"]');
end;
else do;
call define(_col_,'style', 'style=[postimage="c:\temp\red.jpg" ]');
end;
endcomp;
run;
ods pdf close;
ods html close;
thanks for your answer Cynthia.
In the real code the paths are fully qualified.
I got the images, but just one and in a very wrong position.
But your answer is a good news, because if the code is working for you, maybe I should just check my installation with the tech support to see if there is some hot fix missing.
thanks
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.