This example SAS Stored Process creates a custom HTML input form that is used to execute another SAS Stored Process. This provides an alternative to the approach of creating a custom JSP file that is stored on your Web server for the custom HTML input form.
The %stp_ServerPage macro serves an HTML file to the client user. It reads an HTML file from an external file or a SAS catalog, resolves any macro variables, and sends the HMTL file to the client.
Another, slightly different approach is illustrated in Sample 37050 "Creating a custom HTML input form for a SAS® Stored Process".
See Usage Note 19475 "Creating dynamic parameter values for a SAS® Stored Process" for information about creating a dynamic HTML input form for a SAS Stored Process.
Server_Page_Example_1.sas (Example SAS Stored Process code)
Server_Page_Example_2.sas (Example SAS Stored Process code)
stp_ServerPage.sas (Source code for the %stp_ServerPage macro)
Freq_Analysis.html (An example HTML server page)
The %stp_ServerPage macro reads the input HTML file, resolves any macro variables in the file (such as _stpname and _URL) and sends the output to the client.
The HTML file can be stored in an external file or in a SAS catalog. If the _stp_filetype macro variable has a value of CATALOG, the input file will be read from a SAS catalog; otherwise the input file will be read from an external file.
The Server_Page_Example_1.sas SAS Stored Process code:
Assigns the name (_stpname) of the SAS Stored Process that is to be included in the HMTL file that is created.
Assigns the name of the file (_stpfile) that will be read by the %stp_ServerPage macro.
Invokes the %stp_ServerPage macro.
The Server_Page_Example_2.sas SAS Stored Process code:
Specifies that the HMTL file is stored in a SAS catalog.
Assigns the name of the file (which is a SAS catalog entry) that will be read by the %stp_ServerPage macro.
Invokes the %stp_ServerPage macro.
The Freq_Analysis.html file is an example HTML file that is read by the %stp_ServerPage macro and served to the client user.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
File Name: Server_Page_Example_1.sas
/* File Name: Server_Page_Example_1.sas */
/* */
/* This SAS Stored Process assigns the _stpname and _stpfile macro variables, */
/* then it invokes the %stp_ServerPage macro. */
/* */
/* _stpname is the name of the next SAS Stored Process to be executed. */
/* _stpfile is the name of the HTML Server Page file. */
%let _stpname=/Samples/Stored Processes/Sample: Frequency Analysis of Municipalities;
%let _stpfile = C:\server_pages\Freq_Analysis.html;
%stp_ServerPage;
File Name: Server_Page_Example_2.sas
/* File Name: Server_Page_Example_2.sas */
/* */
/* This SAS Stored Process assigns the _stpname, _stpfile and */
/* _stp_filetype macro variables. */
/* Then, it invokes the %stp_ServerPage macro. */
/* */
/* _stpname is the name of the next SAS Stored Process to be executed. */
/* _stpfile is the name of the HTML Server Page file. */
/* _stp_file_type indicates that the input file is in a SAS catalog. */
libname mylib "C:\sas_server_pages";
%let _stpname=/Samples/Stored Processes/Sample: Frequency Analysis of Municipalities;
%let _stp_filetype=CATALOG;
%let _stpfile = mylib.mycat.sample.source;
%stp_ServerPage;
File Name: stp_ServerPage.sas
/* File Name: stp_ServerPage.sas */
/* */
/* This macro reads the HTML server page (_srvpage), resolves */
/* any macro variables in the input records */
/* (such as &_stpname and &_URL) and sends the records back */
/* to the client user. */
/* */
/* Parameters: */
/* &_stpfile - The location of the input HTML file */
/* &_stpname - The name of the SAS Stored process in the HMTL file */
/* &_stp_filetype - A value of CATALOG indicates the HTML file */
/* is in a SAS® catalog; otherwise the HTML */
/* file is an external file. */
%macro stp_ServerPage;
%global _stp_filetype;
%if %upcase(&_stp_filetype) = CATALOG %then
%str(filename _srvpage catalog "&_stpfile";);
%else %str(filename _srvpage "&_stpfile";);
data _null_;
infile _srvpage truncover;
file _webout;
input infile $32755.;
infile = resolve(infile);
put infile;
run;
%mend stp_serverpage;
File name: Freq_Analysis.html
/* File Name: Freq_Analysis.html */
/* */
/* This is an example HTML Server page that is read by the */
/* stp_ServerPage macro and served to the client user. */
<HTML>
<BODY>
<H1>Sample: Frequency Analysis of Municipalities</H1>
This sample illustrates the data analysis capabilities
of SAS Stored Processes.
<FORM ACTION="&_URL">
<INPUT TYPE="HIDDEN" NAME="_program" VALUE="&_stpname">
<HR>
Choose a table to display:<BR>
<INPUT TYPE=RADIO NAME="table" value="city*dept" CHECKED>City by Dept<BR>
<INPUT TYPE=RADIO NAME="table" value="city*week">City by Week<BR>
<INPUT TYPE=RADIO NAME="table" value="dept*week">Dept by Week<BR>
<HR>
<INPUT TYPE="SUBMIT" VALUE="Run Procedure">
<INPUT TYPE="CHECKBOX" NAME="_debug" VALUE="log">Show SAS Log
</FORM>
</BODY>
</HTML>
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Date Modified: | 2009-09-28 13:25:32 |
Date Created: | 2009-09-09 11:36:47 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | SAS Integration Technologies | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |||
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |||
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |||
Microsoft Windows Server 2008 | 9.1 TS1M3 SP4 | |||
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |||
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |||
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |||
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |||
HP-UX IPF | 9.1 TS1M3 SP4 | |||
Linux | 9.1 TS1M3 SP4 | |||
Linux on Itanium | 9.1 TS1M3 SP4 | |||
OpenVMS Alpha | 9.1 TS1M3 SP4 | |||
Solaris for x64 | 9.1 TS1M3 SP4 | |||
Tru64 UNIX | 9.1 TS1M3 SP4 |