Combining graphs/procs with custom HTML in a SAS Stored Process

2

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 '';
  put '';
/** 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;

Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

2 Comments

  1. Wow, this was incredibly helpful!
    Thanks so much Angela - this is exactly what I was looking for!

  2. Very useful stuff. I use it now as a way to flip between different views using a drop down menu in the stored process.

Back to Top