Published on :
Reporting SASHELP

Dynamic Web Form Generation for SAS Execution

This code is also available in: Deutsch Español Français
This script creates a web interface (HTML form). Initially, it queries the 'sashelp.orsales' table to dynamically build a product dropdown list via a macro variable. Then, it uses a DATA _NULL_ step to write the HTML code to the '_webout' output stream (typical for SAS© Stored Processes or SAS© Job Execution), integrating the dynamic list and options for format (HTML, PDF, CSV...) and ODS style.
Data Analysis

Type : SASHELP


The source data comes from the standard 'sashelp.orsales' table to populate the 'product_line' dropdown list.

1 Code Block
PROC SQL
Explanation :
Retrieval of distinct values from the 'product_line' column to create a string containing HTML <option> tags, stored in the 'options' macro variable.
Copied!
1PROC SQL ;
2 select distinct '<option value="'||strip(product_line)||'">'||strip(product_line)||'</option>'
3 into :options separated BY ' '
4 from sashelp.orsales ;
5QUIT ;
2 Code Block
DATA STEP
Explanation :
Writing HTML content to the '_webout' system fileref. The 'resolve' function is used to interpret macro variables (like &options generated previously, or system variables &_srvname) present in the raw data block (cards4).
Copied!
1DATA _null_ ;
2 file _webout ;
3 INPUT ;
4 line=resolve(_infile_) ;
5 put line ;
6 cards4 ;
7
8
9

Pick a report to RUN

10
"get" ACTION="http://&_srvname:&_srvport/&_url?" target="content">
11<INPUT type="hidden" name="_program" value="/User Folders/phil/My Folder/test">
12
13&options
14
15
16
17
18
19
20
21
22
23
24
25
26
27<INPUT type="checkbox" name="_debug" value="log">Show log
28<INPUT type="checkbox" name="_debug" value="time">Show time taken
29
30
31<INPUT type="submit" value="Run">
32
33
35
36
37;;;;
38RUN ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.