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

Objective: To create a legend on a separate page which has the appropriate markers and images for my plot.

I had no issues with the markers.

The images on the other hand, well, need your assistance please.

I have two png images that I'd like side by side (very small) with text next to them, like this:

IMAGE1.png  Image1 description       IMAGE2.png  Image2 description

 

Separate question: How long is too long to research something before coming to the forum? Asking for a friend.

 

Code with pdf output snapshot below. SAS 9.4M7

ods pdf file='C:\Users\MelissaMenier\Pictures\stuff.pdf';
title 
"^{style[Just=L PREimage='C:\Users\Public\Pictures\DM00T_NoDM.png']  }" 
"^{style[font_size=50pt color=red]^{unicode '261a'}^{unicode '0020'}}"
"^{style[Just=C background=WH color=BL font_size=24pt ]That is a standard image. Not the image I would like. } ";
 
proc odstext;
	P "^{style [preimage=""C:\Users\Public\Pictures\DM00T_NoDM.png""]Image does not print in Results Viewer; PDF opens with white question mark in green circle'}";
	p "I'd prefer the image in a PARAGRAPH (P) line, but will settle for a TITLE or FOOTNOTE statement if that's a limitation.";
run;
ods pdf close;

PDF Output Snapshot.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  That white question mark inside the PDF file where you expect an image is like the red X you get in HTML when an image is not found. It's a placeholder for an image, but the image could not be found/accessed when the PDF file was created. Images you point to within the ODS PDF sandwich are actually embedded in the PDF file at the time the PDF file is created.

  Here's my test, using a slightly modified version of your code:

Cynthia_sas_1-1628433711038.png

 

  You'll notice that I wrote my PDF file in the SAME location where the image file was located. However a second test using different locations, also worked, as shown below:

Cynthia_sas_2-1628433757436.png

I would recommend putting the images and the output into the same folder to start to make sure that everything is working (as my first example shows). I find that Windows can be "touchy" about C:\Users, which is why I don't ever try to send output there. I suspect some kind of name issue or access issue.

 

Tell your friend that "how long" depends on each person. If they've made an effort to search for an answer and they've tried debugging on their own and nothing is working, then post a question on the forum. Sometimes, they find that just organizing the question (posting code, explaining the problem) will clarify their thinking and possibly lead to a solution. But if not, then your friend has a question ready to go. My rule of thumb is to ask before I get so frustrated I start yelling at the screen.

Cynthia

PS I'm not sure what you mean when you indicate that the images don't show in Results Viewer. They may or may not show in the default HTML results because ODS was creating PDF output. Whether or not the images show in the HTML Results Viewer will depend on whether the image is accessible when the HTML file is opened. You should be able to open the PDF file with Adobe Reader (as I show in my screen shots) and see the image if the file names, locations, access privileges are OK.

View solution in original post

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

Hi:

  That white question mark inside the PDF file where you expect an image is like the red X you get in HTML when an image is not found. It's a placeholder for an image, but the image could not be found/accessed when the PDF file was created. Images you point to within the ODS PDF sandwich are actually embedded in the PDF file at the time the PDF file is created.

  Here's my test, using a slightly modified version of your code:

Cynthia_sas_1-1628433711038.png

 

  You'll notice that I wrote my PDF file in the SAME location where the image file was located. However a second test using different locations, also worked, as shown below:

Cynthia_sas_2-1628433757436.png

I would recommend putting the images and the output into the same folder to start to make sure that everything is working (as my first example shows). I find that Windows can be "touchy" about C:\Users, which is why I don't ever try to send output there. I suspect some kind of name issue or access issue.

 

Tell your friend that "how long" depends on each person. If they've made an effort to search for an answer and they've tried debugging on their own and nothing is working, then post a question on the forum. Sometimes, they find that just organizing the question (posting code, explaining the problem) will clarify their thinking and possibly lead to a solution. But if not, then your friend has a question ready to go. My rule of thumb is to ask before I get so frustrated I start yelling at the screen.

Cynthia

PS I'm not sure what you mean when you indicate that the images don't show in Results Viewer. They may or may not show in the default HTML results because ODS was creating PDF output. Whether or not the images show in the HTML Results Viewer will depend on whether the image is accessible when the HTML file is opened. You should be able to open the PDF file with Adobe Reader (as I show in my screen shots) and see the image if the file names, locations, access privileges are OK.

MelissaM
Obsidian | Level 7
Thank you so much!
For everything!
I actually was on the right path, so that's good.
It turns out, something is wrong with my image. Perhaps it's not big enough? I used another image from the same location & it worked like a charm!
However, I can work with the image issue (re-scaling, etc).
ballardw
Super User

Have tried placing ALL the Style information after the / ub a P statement in proc odstext? Such as:

I don't have your image file or any other at hand that seem like a good test so this is untested.

 
proc odstext;
	P "Image does not print in Results Viewer; PDF opens with white question mark in green circle"
     /style= [preimage="C:\Users\Public\Pictures\DM00T_NoDM.png"];
	p "I'd prefer the image in a PARAGRAPH (P) line, but will settle for a TITLE or FOOTNOTE statement if that's a limitation.";
run;


The generic syntax for the P statement has style information after the expression it is applied to.

P expression / <FORMAT=format-name> <STYLE=style-override> ;

 

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 1438 views
  • 0 likes
  • 3 in conversation