Write and run SAS programs in your web browser

How to read a png file saved at home directory location in SAS Studio

Reply
Occasional Contributor
Posts: 14

How to read a png file saved at home directory location in SAS Studio

Hi All,

 

I was able to place a png & htm file after running following code,

 

%let name=bar1;
FILENAME odsout "&_SASWS_/charts";   /* This allows me to output bar1.png being created in my home directory under charts */
goptions xpixels=480 ypixels=300 device=png noborder cback=white;
ods listing close;
ods HTML path=odsout body="&name..htm" style=minimal;
title;
footnote;
proc gchart data=running; vbar Date / sumvar=Mile_3 clipref frame type=sum
 coutline=black raxis=axis1 maxis=axis2
 des="" name="&name.";
run; quit;

 

Now how do I pull/read/access/fetch the file BAR1.png or BAR1.htm back in my proc report if I intend to email this image alongwith proc report output?

 

proc report data = running STYLE = [PREHTML = %UNQUOTE(%STR(%')
 <table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
 <td align="center"><strong>3 Mile Race Times</strong></td></tr>
 <tr><td align="center">
 <img src="what-do-I-mention-here" width="480" height="300"
align="middle" />
 </td></tr></table>
 %STR(%'))];
column Date Mile_1 Mile_2 Mile_3 Mile_4;
define Date / display;
define Mile_1 / display;
define Mile_2 / display;
define Mile_3 / display;
define Mile_4 / display;
run;
quit;

 

Anybody who could help please?

 

Regards,

Arpit

Frequent Contributor
Posts: 129

Re: How to read a png file saved at home directory location in SAS Studio

Hi Arpit,

 

did you already try this?

________________________

- Cheers -

Occasional Contributor
Posts: 14

Re: How to read a png file saved at home directory location in SAS Studio

Ok, so preimage works fine,

 

proc report data = running STYLE=[PREIMAGE="&_SASWS_/charts/bar16.png"];
column <varlist>;
......
run;
quit;

 

but that's not what I am looking for(thank you for suggesting though, I didn't know).

 

Reason - I am interested to hit the source of image (.png in this case sitting at the home directory of SAS Studio Online account) and embed it in HTML under PROC REPORT so that when I send the output to any mobile device (irrespective of iPhone or adroid or screen size) the solution doesn't look messy, depending on platform we're sending output to.

 

Does this give a clear picture of the problem statement?

Reference link : http://support.sas.com/resources/papers/proceedings12/240-2012.pdf

Super User
Posts: 11,134

Re: How to read a png file saved at home directory location in SAS Studio

You would want to replace

"&_SASWS_/charts"];

with

"&_SASWS_./charts"];

 

The Period after the _ denotes the end of the macro variable. Otherwise the macro processor looks for a macro variable named _SASWS_/CHARTS and will complain as the / is not valid in a macro variable name.

 

Since I don't know what &_SASWS_ might look like I'm not sure what modifications may be needed to get to be a valid src=argument.

 

 

Super User
Super User
Posts: 6,845

Re: How to read a png file saved at home directory location in SAS Studio

??

There is no need to insert a period.  Macro variable names cannot contain /. 

Super User
Posts: 11,134

Re: How to read a png file saved at home directory location in SAS Studio

In addition to @Oligolas's suggestion you may want to test the results of PREIMAGE in lieu of POSTIMAGE. You can get different appearance depending on order of insertion.

SAS Super FREQ
Posts: 8,820

Re: How to read a png file saved at home directory location in SAS Studio

And another suggestion is to carefully consider your destination of choice. ODS HTML does NOT embed the image you reference in the file. ODS HTML only makes an <IMG> tag that points to the location of the image. So you would need to send your HTML file and the image file in the email.

On the other hand, if you emailed PDF (or RTF), but for mobile, PDF is better, then the image WOULD be embedded in the PDF file and all you would need to do is send the PDF file.

cynthia
Super User
Super User
Posts: 6,845

Re: How to read a png file saved at home directory location in SAS Studio

[ Edited ]

If you really want to embed your PNG file into the HTML data you are generating then you will need actually embed the content of the PNG file and NOT just code a link to a separate file.

 

http://www.techerator.com/2011/12/how-to-embed-images-directly-into-your-html/

 

Ask a Question
Discussion stats
  • 7 replies
  • 389 views
  • 0 likes
  • 5 in conversation