2

I am running into an error when trying to use ods excel after defining a style named excel via ods template. I was wondering if anyone could explain why this is happening as I thought ods styles and ods destinations were two completely separate things.

The following ods excel statement works fine:

ods excel file="%sysfunc(pathname(work))\x.xlsx";
proc print data=sashelp.class;
run;
ods excel close;

But if I try to run it after running the below proc template code, I get an error.

proc template;
  define style excel; 
    parent=styles.htmlblue;
    class graph       / attrpriority='none';
    style graphdata1  / contrastColor=#416FA6 markersymbol='circlefilled';
    style body from body / pagebreakhtml=_undef_; * REMOVE THE HORIZONTAL RULE;
  end; 
run; 

ods excel file="%sysfunc(pathname(work))\x.xlsx";
proc print data=sashelp.class;
run;
ods excel close;

The error is:

ERROR: Could not find method.
ERROR: No body file. EXCEL output will not be created.

I can just rename my style to something other than excel to fix the issue, but I don't understand why this is happening in the first place. Is anyone able to explain? Thanks.

Robert Penridge
  • 8,424
  • 2
  • 34
  • 55
  • 1
    Is the error from PROC TEMPLATE? or PROC PRINT? Also I don't see any attempt to use the new style. – Tom Jun 26 '19 at 17:39
  • @tom The error is from the `ods excel` statement I believe. And correct - no attempt to use the new style is necessary for this to start triggering the error. – Robert Penridge Jun 26 '19 at 17:42
  • 1
    I can confirm that this creates an error but not sure why. Tested in 9.4M6 – Reeza Jun 26 '19 at 18:08
  • What happens if you use `styles.excel` instead of `excel` for the path name? – Tom Jun 26 '19 at 19:44
  • @Tom Yup - that fixes it. If you put it as an answer I'll accept it. I guess there's some kind of naming conflict going on that fully qualifying it avoids. – Robert Penridge Jun 26 '19 at 20:41

1 Answers1

0

From comments, thanks @Tom:

Use ods styles.excel instead of ods excel:

ods styles.excel file="%sysfunc(pathname(work))/x.xlsx";
proc print data=sashelp.class;
run;
ods styles.excel close;
Sanek Zhitnik
  • 716
  • 1
  • 10
  • 25