General SAS CGI Web Interface - With demo form

A general purpose program to output SAS macro variables from HTML web page forms. Converts any web form into SAS variables.

The web form below demonstrates the use of sas.cgi a CGI program which starts a SAS session and passes ANY AND ALL web form values to SAS as macro code in a macro variable. With this cgi program you will never have to write a cgi script. All of your programming can be in SAS and the web form itself. Both the web server CGI and SAS are running in a UNIX environment. Only one line of SAS code is required to capture the form values

The SAS program demonstrates the use of the CGI script using the form below. Use the Netscape command View:Document Source to see this forms HTML code.

How it Works

The form below sends the form contents to sas.cgi via our web server. Sas.cgi starts a SAS batch session on a different computer with the sas program and passes the form contents as a parameter. The parameter is macro code which when included in the program evaluates ALL of the field names and values as sas macro variable assignments. The SAS session and the web server communicate via stardard in/out over any network via 'rsh'


Each field in a web form in defined in the HTML code as having a name and a value. The name and value pairs are sent by the web browser in the format:
The cgi script reformats the values into the format:
%let name1=value1; %let name2=value2...
The values are then added to a SAS batch command:
sas -sysparm "%let name1=value1; %let name2=value2..."...
In the web form 'hidden' fields are used to define runtime requirements for the CGI script such as where sas is located etc.:
name=debug value=1                            * display all name-value pairs;
name=program value=recfin                     * name of SAS program 'value'.sas;
name=logpath value=/usr/mrfss/www/saslogs/    * where to send SAS log;
name=progpath value=/usr/mrfss/programs/www/  * location of SAS program 'value'.sas;
name=saspath value=/opt/sas611/               * location of SAS executable
name=server value=lingcod                     * name of computer where SAS is located					
All other form 'names' and 'values' are up to you, the SAS programmer. All 'names' must be valid SAS macro names.

The single line:

in your SAS program will assign all the form values to SAS macro values.

An additional macro variable 'pid' is added to the program. This is the UNIX process id code which is used to serialize the log file. The file is the name of the sas program with the pid added. The name of the log file for the SAS program demo with process id 12345 would be: demo12345.log. The pid can be used to serialize output files also.

To see all the values from the form add the hidden field name=debug value=* to your form or add debug=1& to the beginning of the query string and resubmit the form. When sas.cgi sees a debug value it will print out all of the form data pairs before submitting the request to SAS. So the minimum submission to test would be The script returns the single form value for 'debug' and the process id for the script execution on the web server

Values from multiple selections in a combo box are returned with the values dot '.' delimited. The delimiter can be changed in the CGI program. Let me know if there is a problem, Wade


Check Box

Debug this form

Option Box

Taxonomic Super Group

Radio Buttons

Common Super Group

Multiple Option Box

Oregon Coastal Counties

Text Boxes