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

Hi all,

 

I am placing SGPLOTs in an ODS html: all fine, no errors, but opening the HTML I only get to see a little X with the text "The SGPlot Procedure" (attached: SGPLOT.PNG - no it is not: png was refused but I think you know what I mean, ;-)). All other output is produced as expect though in this case these are just prints...

 

Does anyone have a solution for this, I did not find anything googling this and I do see a lot of ods html's followed by proc sgplots...

 

PS: I am on SAS 9.3 using EG here.

 

For completeness I show you the code, sample data is difficult but as said: I have no data trouble, no syntax trouble - outside the html all works fine and the expected outputs can be produced. I also verified that the template used did not break it (it is included below because the ods html statement uses it):

/******************************************/
/* Aanpassingen aan de stijl voor de html */
proc template;
 define style styles.nobreak;
 parent=styles.statistical;
 /* Haalt de break na elke procedure eruit */
 style body from body / pagebreakhtml=_undef_;
 end;
run; 
%let pbreak=%nrstr(<p style="" page-break-after:always""><br></p><hr/>); 
/******************************************/

/*****************************/
/* Creëren HTML met ODS HTML */
filename HtmlDest "&OUTPUT_PATH./DQ_Master_&DTSTAMP..html";* mod;

ods listing close;
ods html file=HtmlDest (title="Data Kwaliteit MasterFile")
  style= styles.nobreak;

proc sgplot data=HistoFull;
  vbar Klasse / 
    response=PCT_TOT_EAD 
    group=T groupdisplay=cluster grouporder=data
    ;
  xaxis display=(nolabel) discreteorder=data;
  yaxis label='% Totale EAD' grid;
  keylegend / location=inside position=topright;
run;

ods html close;
ods listing;

Thanks in advance for any help...


Best,

Dirk

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Instead of ods html file=

try

ods html path="&output_path./" (url=none) body="dq_master_&dtstamp..html"

HTML behaves a bit differently than several of the other ods destinations because of such options as FRAMES . The URL=None part has the code generate a relative path to sub-elements  such as frame or contents so you don't have to use absolute addressing to the other bits.

View solution in original post

4 REPLIES 4
Reeza
Super User

HTML files don't embed images, they get linked to instead. 

So you need to ensure where the gpath is set is accessible to whomever is opening the HTML file or package them together somehow. 

 

HTML5 will embed images into the file, so it's a quick workaround and it also means it's easier to share the files.

ods html file= " .... " gpath = 'Path to where images will be stored';

@dirkvk wrote:

Hi all,

 

I am placing SGPLOTs in an ODS html: all fine, no errors, but opening the HTML I only get to see a little X with the text "The SGPlot Procedure" (attached: SGPLOT.PNG - no it is not: png was refused but I think you know what I mean, ;-)). All other output is produced as expect though in this case these are just prints...

 

Does anyone have a solution for this, I did not find anything googling this and I do see a lot of ods html's followed by proc sgplots...

 

PS: I am on SAS 9.3 using EG here.

 

For completeness I show you the code, sample data is difficult but as said: I have no data trouble, no syntax trouble - outside the html all works fine and the expected outputs can be produced. I also verified that the template used did not break it (it is included below because the ods html statement uses it):

/******************************************/
/* Aanpassingen aan de stijl voor de html */
proc template;
 define style styles.nobreak;
 parent=styles.statistical;
 /* Haalt de break na elke procedure eruit */
 style body from body / pagebreakhtml=_undef_;
 end;
run; 
%let pbreak=%nrstr(<p style="" page-break-after:always""><br></p><hr/>); 
/******************************************/

/*****************************/
/* Creëren HTML met ODS HTML */
filename HtmlDest "&OUTPUT_PATH./DQ_Master_&DTSTAMP..html";* mod;

ods listing close;
ods html file=HtmlDest (title="Data Kwaliteit MasterFile")
  style= styles.nobreak;

proc sgplot data=HistoFull;
  vbar Klasse / 
    response=PCT_TOT_EAD 
    group=T groupdisplay=cluster grouporder=data
    ;
  xaxis display=(nolabel) discreteorder=data;
  yaxis label='% Totale EAD' grid;
  keylegend / location=inside position=topright;
run;

ods html close;
ods listing;

Thanks in advance for any help...


Best,

Dirk


 

ballardw
Super User

Instead of ods html file=

try

ods html path="&output_path./" (url=none) body="dq_master_&dtstamp..html"

HTML behaves a bit differently than several of the other ods destinations because of such options as FRAMES . The URL=None part has the code generate a relative path to sub-elements  such as frame or contents so you don't have to use absolute addressing to the other bits.

dirkvk
Fluorite | Level 6
I am going to implement this...
dirkvk
Fluorite | Level 6

Hi all,

 

Before seeing any of your posts, I figured it out. I wanted to share my solution with you guys.
Sorry that I haven't used any of your possibly excellent solutions (yet), I will read them all and possibly change to that once time permits. I needed a solution ASAP for this

 

the story goes like this:

 

SAS runs on a linux machine where the root of things is "data2/data/" and somewhere below that my html file is created.

I have no access to the linux other than through the SAS/EG, which sits on on a Win Server 2008 that I access through RDC.

On the latter, which is also the location where I access the produced html, the same location as above is "\\sv-secret\", ;-).

 

So what happens is: the html is pointing the png it produced to a location that is not existing and therefore it is not showing up in the html.

 

My solution was the following:

- explicitely point the png files to the right location (which I did not do before) - still linux though (see gpath remark below)

- read in the produced html (rnamed toProcess.html)

- alter the "data2/data/" to become "\\sv-secret\" and while at it change all / to \ 

- write out the latter to a new html file

 

Note, before that I tried gpath = using the target for that as the "\\sv-secret\" but SAS complained about that location not existing (which does not on the linux where the SAS is running) and said it ignored that...

 

It is convoluted but it works - as said, I might change for something nicer when time permits, :-D.

 

Thanks 4 your answers!

/* Post-processing the produced HTML */
data html_in;
length FullLine $32767.;
infile "&OUTPUT_PATH./ToProcess.html" dlm='°' lrecl=32767 dsd;
/*if anyone has a better idea for the dlm='°', do let me know, :-). 
I basically do not want to stop reading a record before it ends,
that's why I took a dlm which is a char that doesnt exist in the file
- all quick dirty but working, :-D */ input FullLine $; run; data html_out; set html_in; if index(FullLine,'.png') and index(FullLine,'src=') then do; FullLine = tranwrd(tranwrd(FullLine,'/data2/data/','\\sv-secret\'),'/','\'); end; run; data _null_; set html_out; file "&OUTPUT_PATH./DQ_Master_&DTSTAMP..html"; put FullLine; run;

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
  • 4 replies
  • 4421 views
  • 2 likes
  • 3 in conversation