How to use custom PROC TEMPLATE code in a stored process that is opened using the SAS® Add-In for Microsoft Office


When you open a stored processes in the SAS Add-In for Microsoft Office, the _ODSSTYLE is set to AMODefault. If you, instead, want to use a custom style created by PROC TEMPLATE, you can use code that is similar to the following.

*ProcessBody;

/* set the ODS destination explicitly */

%let _ODSDEST=tagsets.msoffice2k;

/* allows you to write to a temporary template catalog for this stored process */

ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);   

proc template;                   /* template code goes before the stpbegin statement */
  define style mydefault;
  parent = styles.default;
  style GraphData1 from GraphData1 /
     Color=blue;
  style GraphData2 from GraphData2 /
     Color=red;
  style GraphData3 from GraphData3 /
     Color=orange;
  end;
run;

%let _odsstyle=mydefault;       /* hard-code this stored process macro before the stpbegin statement */
%let _odsstylesheet= ;

%STPBEGIN;

data temp1;
  input exchanges grouplabel qty;
cards;
1 1 10
1 2 20
2 1 30
2 2 15
;
run;

ods graphics on / imagefmt=gif imagemap=on imagename='mygraph' border=off width=5in;

ods &_odsdest style=&_odsstyle;

proc sgpanel data= temp1 noautolegend;
    panelby grouplabel / novarname layout=COLUMNLATTICE onepanel;
    hbar exchanges / group=grouplabel response=qty datalabel nooutline;

    rowaxis discreteorder=data DISPLAY=(NOLINE NOTICKS);
    colaxis display = none;
run;
quit;

ods &_odsdest close;
ods graphics off;

;*';*";*/;quit;
%STPEND;