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

Hi,

Below is a snapshot of my code:

 

%let report_dir = %sysfunc(pathname(work));options missing = '';
ods escapechar = "^";

ods pdf file="&report_dir/Report.pdf" pdftoc=1 startpage=yes bookmarklist=hide;

Title j=l "^{style[preimage='C:\Pre\B2.png']}";
footnote j=r "^{style[preimage='C:\Pre\B.png']}";
footnote2 j=c font='Arial' h=12pt "Report for Quarter1";

ods pdf startpage=now;
ods proclabel 'Cover Page';

proc odstext;
p;p;p;p;
p "Report"/ style=[font=(Arial, 30pt) foreground=black just=c font_weight=bold];
p;p;p;p;p;p;p;p;p;
run;

ods pdf startpage=now;
footnote;

 

ods proclabel ="Summary" ;Title j=c font='Arial' h=18pt "Summary";%summary_pg(PAGE1);

ods pdf close;

 

My pdf is created in the way I want, but the cover page comes out with ? on the top left and bottom right with the below error in the log:

 

ERROR: Unable to load image C:\Pre\B.png; default image will be used instead.

 

Where should I save my image such that SAS is able to retrieve it?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Try wrapping the preimage value in extra quotes.

 

ods escapechar='^';
ods pdf file="&report_dir./Report.pdf" pdftoc=1 startpage=yes bookmarklist=hide;

Title j=l "^{style[preimage=""&report_dir./B.png""]}";
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

17 REPLIES 17
Reeza
Super User
Are you running on a server? Does your computer have access to the C drive? Can you post the exact error message from the log? There's usually other indications in there that will illustrate what the cause of the issue is.
new_sas_user_4
Obsidian | Level 7

I have a excel file saved on my C: drive which I import at the beginning so I assume SAS can access my C: drive.

I am running on a BI_Server

 

ERROR: Unable to load image C:\Pre\B.png; default image will be used instead. (<--- the entire message)

Reeza
Super User

@new_sas_user_4 wrote:

I have a excel file saved on my C: drive which I import at the beginning so I assume SAS can access my C: drive.

I am running on a BI_Server

 

ERROR: Unable to load image C:\Pre\B.png; default image will be used instead. (<--- the entire message)


That's not necessarily true - it depends on how you imported the file. If you did it via the GUI rather than code it could very well be that SAS cannot see your C drive. In that case the 'import step' actually includes an upload step to upload the data to the server. 

new_sas_user_4
Obsidian | Level 7

Yea, I do use the File--> Import option to import the excel file, thanks for explaining that!

Is there a way I can save the image on the server then ?

Reeza
Super User
Depends on your setup and installation - likely a better question for a colleague or someone in your company. FYI - if you have a SAS server you likely have other SAS users you can talk to - find out who they are 🙂
new_sas_user_4
Obsidian | Level 7

So, I have to find a way to save the image on the server or a drive that SAS can access ....right?

ballardw
Super User

@new_sas_user_4 wrote:

Hi,

Below is a snapshot of my code:

 

%let report_dir = %sysfunc(pathname(work));options missing = '';
ods escapechar = "^";

ods pdf file="&report_dir/Report.pdf" pdftoc=1 startpage=yes bookmarklist=hide;

Title j=l "^{style[preimage='C:\Pre\B2.png']}";
footnote j=r "^{style[preimage='C:\Pre\B.png']}";
footnote2 j=c font='Arial' h=12pt "Report for Quarter1";

ods pdf startpage=now;
ods proclabel 'Cover Page';

proc odstext;
p;p;p;p;
p "Report"/ style=[font=(Arial, 30pt) foreground=black just=c font_weight=bold];
p;p;p;p;p;p;p;p;p;
run;

ods pdf startpage=now;
footnote;

 

ods proclabel ="Summary" ;Title j=c font='Arial' h=18pt "Summary";%summary_pg(PAGE1);

ods pdf close;

 

My pdf is created in the way I want, but the cover page comes out with ? on the top left and bottom right with the below error in the log:

 

ERROR: Unable to load image C:\Prepaid\B.png; default image will be used instead.

 

Where should I save my image such that SAS is able to retrieve it?

 

Thanks


The section of your message that I highlighted in blue is on one of the reasons we say to copy the code and messages from the log and paste them into a code box opened with the {I} or "running man" icons. The box will preserve formatting and indicate what was actually in the log.

 

If you look at the code I highlighted in RED you can see that the "code" does not conform to the error message. The error message says that you were attempting to use files in the directory C:\Prepaid but the code shows C:\Pre. So at this point we really can't tell what else you may have submitted that is not in your shown code.

 

Understanding your environment, server vs local install, and paths and permissions are important.

new_sas_user_4
Obsidian | Level 7

I am sorry,

the error message is :ERROR: Unable to load image C:\Pre\B.png; default image will be used instead.

 

I modified the name of the folder under C: before posting.

ChrisHemedinger
Community Manager

If you're using SAS Enterprise Guide to run your code on a remote server, it won't be able to see your C: drive.

 

You can copy the image files to the server (say, to the %sysfunc(pathname(work)) folder) by using the Copy Files task in EG.  And then change your program code to reference the images from there.  Make sure the Copy Files task runs before your program.

 

The Copy Files task accepts macro variables/functions as path/filename descriptors.

 

Chris

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
new_sas_user_4
Obsidian | Level 7

I am working on SAS EG version 6.1

I dont see the Copy files option under Tasks-->Data

can I install it by any chance?

Reeza
Super User

That depends on your set up. If they've given you permissions to install extensions you should be fine - most places I've worked have had that feature locked down though. 

 


@new_sas_user_4 wrote:

I am working on SAS EG version 6.1

I dont see the Copy files option under Tasks-->Data

can I install it by any chance?


 

ChrisHemedinger
Community Manager

Steps to install are in this blog post.  You will need to download a ZIP, copy a DLL into your user profile area, and probably change a security flag on that DLL (all doc'd in the ZIP file instructions).

 

The task is built into EG v7.13 and later.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
new_sas_user_4
Obsidian | Level 7

Thanks Chris!

 

I did copy the SAS.tasks.CopyFiles61.dll to the custom folder but can't see it(under Add-in) when I reopen my SAS session 😞

ChrisHemedinger
Community Manager

@new_sas_user_4 - Did you complete this step after copying the file?

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 17 replies
  • 3833 views
  • 1 like
  • 4 in conversation