Search code examples
sassas-ods

ods excel and proc template


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.


Solution

  • 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;