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 demo.sas demonstrates the use of the CGI script using the form below. Use the Netscape command View:Document Source to see this forms HTML code.
name1=value1&name2=value2...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 locatedAll other form 'names' and 'values' are up to you, the SAS programmer. All 'names' must be valid SAS macro names.
The single line:
&sysparm.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 http://www.psmfc.org/cgi-bin/recfin/sas.cgi?debug=1. 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