Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next

Building a Basic Web Report

The Building a Basic Web Report sample demonstrates the process of building a basic Web report with a GIF graph and drill-down links using the Output Delivery System (ODS).


The Input Component

The sample uses a form submission that is controlled by JavaScript. Each of the sample links uses JavaScript to set one or more field values and submit the form. The sample has no input fields because it has no user-controlled options. You can access the different reports and program components from the default location:

   http://yourserver/sasweb/IntrNet8/dispatch/webreport.html

The Program Component

General Information

To begin generating HTML output by using ODS, submit the following statement:

   ods html ods-options path=&_tmpcat (url=&_replay) rs=none;

The ODS options control the type and destination of the HTML output that is generated by your program. At the end of your program, include the following line of code:

   ods html close;

The SAS source code for your program is placed between these two ODS statements. For more detailed information about using ODS with the Application Dispatcher, refer to The Output Delivery System (ODS).

HTML Sales Report

To create a simple HTML sales report, use an ODS HTML statement along with the REPORT procedure. This report lists the total sales for each product by region.

The program for this report looks like

   ods html body=_webout path=&_tmpcat (url=&_replay) rs=none;                                                            
                                                                                                                       
   proc report data=sashelp.shoes;                                                                                        
      column region product sales;                                                                                         
      define region / group;                                                                                               
      define product / group;                                                                                              
      define sales / analysis sum;                                                                                         
         break after region / ol summarize suppress skip;                                                                   
   run;                                                                                                                   
                                                                                                                       
   ods html close;                                                                                                        

Sales Report with GIF Graph

By adding the GCHART procedure to the program, you can add a GIF graph to the HTML sales report.

The following are the GOPTIONS and PROC GCHART portions of the program, which define the GIF graph. The GOPTIONS and GCHART options are chosen to make the graph attractive and can be changed according to preference.

   goptions device=gif xpixels=600 ypixels=550                                                                                  
      transparency;                                                                                                     
                                                                                                                            
   proc gchart data=sashelp.shoes;                                                                                            
      hbar3d region / sumvar=sales                                                                                             
         sum space=.6                                                                                            
         subgroup=product                                                                                        
         shape=cylinder                                                                                          
         patternid=subgroup                                                                                      
         legend=legend1;                                                                                         
      label product='Shoe Style';                                                                                              
   run;

Sales Report with Java Applet Graph

Simple changes to the GOPTIONS and ODS HTML statements in the program enable you to add a Java applet graph to the sales report. The DEVICE=GIF option in the GIF graph program is changed to DEVICE=JAVA. In addition, in the ODS HTML statement, an ATTRIBUTES= option uses CODEBASE= to specify the location of the SAS/GRAPH Java Applets:

   attributes=(codebase="&_grafloc");                                                               

Sales Report with Drill-down Links

You can add drill-down links to the region column of the sales report by using a separate detail program and a temporary data set. These drill-down links enable you to see the data divided into smaller reports by region.

The following portion of the program creates the temporary data set (WORK.SHOES). The data set contains a new drill-down link variable (REGLINK) with HTML anchor tags added to the region name.

   data shoes;                                                                                                                            
      length reglink $300;                                                                                                                 
      label reglink='Region';                                                                                                              
      set sashelp.shoes;                                                                                                                   
      reglink= '<a href="' || "&_URL" || "?_service=&_service" ||                                                                          
         '&_program=' || "&_pgmlib..&_pgmcat..report3d.source" ||                                                                           
         '&region=' || urlencode(trim(region)) || '">' ||                                                                                   
         htmlencode(trim(region)) || '</a>';                                                                                                
   run;                                                                                           

You can then generate the report by using a PROC REPORT statement similar to the one used to create the simple HTML sales report. The main difference is that the variable REGION is replaced by the variable REGLINK. To view the complete program, click on the program link from the Building a Basic Web Report sample page.

Clicking on a drill-down link displays the detail data for that region on a separate HTML page. The detail data report is created by a separate detail program, which consists of an ODS HTML statement with a PROC REPORT statement.

Sales Report and GIF Graph with Drill-down Links

You can add the GIF graph back to the report so that both the graph and the tabular report contain drill-down links. The program now creates a temporary copy of the data set with two new character variables: one for the tabular drill-down (REGLINK) and one for the graph drill-down (REGHREF). The tabular drill-down value must contain the full HTML anchor tag with the HREF URL and with region name. This URL is accessed when the appropriate portion of the graph receives a click event.

The following code shows the new variable in the data set for the graph's drill-down links.

   data shoes;                                                                                                                            
      length reglink $300 reghref $300;                                                                                                    
      label reglink='Region';                                                                                                              
      set sashelp.shoes;                                                                                                                   
      reghref = 'href="' || "&_URL" || "?_service=&_service" ||                                                                            
         '&_program=' || "&_pgmlib..&_pgmcat..report3d.source" ||                                                                          
         '&region=' || urlencode(trim(region)) || '"';                                                                                     
      reglink = '<a ' || trim(reghref) || '>' ||                                                                                           
         htmlencode(trim(region)) || '</a>';                                                                                               
   run;                                                                                                                                 

Use PROC GCHART to generate the horizontal three-dimensional bar chart, and use PROC REPORT to generate the report. Note that the variables REGLINK and REGHREF are specified as the values for the HTML options. This controls the drill-down behavior for the graphic and report that are generated.

The same detail program, consisting of an ODS HTML statement and a PROC REPORT statement, is used for the detail reports. You can now display detail data for each region on a separate HTML page by clicking on the graph or on the region links in the table.


Contents SAS/IntrNet 8.2: Application Dispatcher Previous Next