BookmarkSubscribeRSS Feed
Scooby3g
Obsidian | Level 7

Hi,

 

I am trying to create a PDF file using Jpeg images from a folder but it doesn't seem to like the images 1 to 13 can be attached. Below is a sample of my code.

Any suggestions is appreciated!! 

 

options orientation=landscape
        papersize=A4
        topmargin=.5in
        bottommargin=.5in
        leftmargin=.5in
        rightmargin=.5in;
		ods noproctitle;
ods escapechar="^";

title1 j=left "#S={preimage='&logo'}";
footnote1 "Report generated on &SYSDATE9. and reflects data available at the time of data extraction.";

ods pdf file="&pdf_output_A";
ods graphics on;
ods escapechar="#";


	ods text="#S={backgroundimage='Data\Reports\Report_Images\Image1.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image2.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image3.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image4.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image5.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image6.jpeg'}";
	ods text="#S={backgroundimage='\Data\Reports\Report_Images\Image7.jpeg'}";

ods pdf close;
6 REPLIES 6
ballardw
Super User

What symptom(s) do you get that tell you PDF doesn't like the image files?

 

Does the path to your image files include the drive or the mount point for the disk they are on? If not the path is likely to be treated as relative to where SAS executes and may not be finding them.

Scooby3g
Obsidian | Level 7

Hi ballardw! 

Apologies for being unclear. For clarification, the sample code that I provided generates the PDF file but without  images1, image2, image3 etc.

 

Below is the SAS log that I generated but with only image 1 and 2. (I had the same output results when I tried to run the SAS script with Image 1 to 13 but wanted something trimmed down for this post)

Scooby3g_0-1722282073907.png

 

ballardw
Super User

Not so tongue-in-cheek comment: if the text of your file paths is so sensitive you can't share them you may have other issues related to security to address.

 

Doesn't answer the question about the paths and can they be seen from where SAS executes with at least READ privileges. If your SAS runs on a server then the SERVER session needs to have access to the path. I see that part of your path starts with \\ so possibly a server name.

Suggestion: Move a copy of one of those files to some location you know your SAS session can use such as your work library and test the code pointing to that one. One file. no reason to make this complicated.

 

Also, if by any chance there are macro variables in that path they won't resolve because of the single quotes around your file path/name.

ChrisNZ
Tourmaline | Level 20

From the documentation:

 

     BACKGROUNDIMAGE="string" specifies an image in a table, table cell, or graph to use as the background.

 

so this option does not set a page background.

 

To do that, use proc template as shown here.

ChrisNZ
Tourmaline | Level 20

 

What you can also do is create empty graphs that have a background.

 

ods pdf file="~/pdf_output_A.pdf";
goptions border iback='~/IMG.png' imagestyle=fit ;
proc gslide; 
run;
ods pdf close;
Ksharp
Super User

Is it what you are looking for ?

%let path= c:\temp ;

options nodate nonumber;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics /width=3in height=3in reset=index noborder imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
reg x=height y=weight/cli clm;
run;

ods graphics /width=3in height=3in reset=index noborder imagename='PPS' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;

ods graphics /width=3in height=3in reset=index noborder imagename='SS' outputfmt=png ;
proc sgplot data=sashelp.class ;
ellipse x=height y=weight/group=sex;
scatter x=height y=weight/group=sex;
run;

ods graphics /width=3in height=3in reset=index noborder imagename='S' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight/group=sex datalabel=name;
run;

ods pdf file="&path.\want.pdf" style=minimal dpi=300 ;
data x;
x=' ';y=' ';output;
x=' ';y=' ';output;
run;
title;
proc report data=x nowd noheader style={outputwidth=100% };
column x y;
define x/display;
define y/display;
compute y;
n+1;
if n=1 then do;
call define('x','style','style={ preimage="&path\FAS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\PPS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
if n=2 then do;
call define('x','style','style={ preimage="&path\SS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\S1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
endcomp;
run;

ods pdf close;

Ksharp_0-1722306002203.png

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 809 views
  • 2 likes
  • 4 in conversation