Combining Graphs/Procs with Custom HTML in a SAS Stored Process

This post was kindly contributed by real business intelligence for real users - go there to comment and to read the full post.

The %STPBegin and %STPEnd macros are pretty powerful pieces of code for SAS Stored Processes. They embed all sorts of information on devices, where content is located, and just make everything work. However for creating those fancy custom HTML forms or layouts, ods html is needed instead. I’ve written about this before, however I did not include the trick to get your procedure output to work in conjunction with the custom HTML code. Essentially you need to include a ODS HTML statement above the proc step and leave it open.

A great reference to start with is actually from instructions on converting SAS programs from use in SAS/IntrNet to SAS Stored Processes. http://www2.sas.com/proceedings/forum2007/023-2007.pdf

Here is an example with some comments to assist with the locations for this information.
*********************************************************************
/*Open the _webout location*/
ods html body=_webout (no_bottom_matter) path=&_tmpcat  (url=&_replay);

/* This is where SAS Procs can go to produce output to the website*/

/*Close the _webout location to allow the data _null_ step to write to it*/
ods html close;

/*This is where Data Null HTML Code can go*/
data _null_;
  file _webout;
  put ‘<html>’;
  put ‘<body>’;
/** INSERT OTHER HTML CODE HERE **/
run;

/*Reopen the _webout location for SAS Procs to write to.*/ods html body=_webout (no_top_matter) path=&_tmpcat (url=&_replay);

/* This is where SAS Procs can go to produce output to the website*/

proc gchart data=sashelp.shoes;
   vbar region/sumvar=sales;
quit;

/*Closes the web output location.*/
ods html close;

This post was kindly contributed by real business intelligence for real users - go there to comment and to read the full post.