Tải bản đầy đủ (.pdf) (377 trang)

building web applications with sasintrnet® a guide to the application dispatcher

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.4 MB, 377 trang )




Praise from the Experts


“While building SAS/IntrNet applications, I would like nothing better than to have someone with
the skills of Don Henderson looking over my shoulder. Other than some SAS-L posts and a few
personal e-mail messages, this desire went unrealized. That was until I read Don’s book, Building
Web Applications with SAS/IntrNet
®
: A Guide to the Application Dispatcher.
“This book picks up where SAS documentation leaves off. It shows how to increase the
functionality of the SAS/IntrNet Application Dispatcher to solve problems commonly
encountered when building Web-based SAS applications. This book also supplies a host of ‘best
practices’ that can help keep one from creating future difficulties.
“An example of the gems that Don has unearthed is the INVSESS option. This option allows
developers to implement friendlier responses to failed attempts to reconnect to a session. Along
with techniques to refresh long-running requests, this book shows how to partially overcome the
problem of user sessions that time-out from user inattention.
“One of the most helpful chapters is Chapter 11, “Tools and Techniques for Debugging.” One
especially useful tip is to seed programs under development with %testPrint macros to
conditionally print intermediate results. This chapter also provides good guidance on how to run
Application Dispatcher programs in a stand-alone mode.
“In my opinion, this is a must-have book if one is responsible for creating or maintaining Web-
based SAS applications.”
Michael Davis


“At long last we have a comprehensive book on the intricacies of SAS/IntrNet programming! Don


Henderson has written the definitive, authoritative book on how to develop SAS/IntrNet
applications so that you can easily host your SAS programs on the Web. There is so much
information packed into this book that you will find something that you did not know in every
chapter. Though I have been working with SAS/IntrNet for many years, I was amazed at the
volume of information that I was not aware of.
“There are several chapters of this book that will allow you to recoup the book’s purchase price,
almost immediately. Chapter 7, “Various Techniques to Generate HTML,” is a case in point. It
takes you through increasingly advanced material, moving from using simple PUT/FILE
statements, to extending the Output Delivery System to the Web, to using SCL submit blocks, to
including HTML from external sources, to using SAS Server pages, and finally to using design-
time controls. All of these techniques have great merit; and this chapter explains how and when to
use them while providing great examples. This chapter will save you hours of research and
development time.
“Another chapter that would have saved my staff at least a week’s worth of work is Chapter 19,
“Handling On-Demand Long-Running Requests.” Many organizations face the unenviable
prospect of having to offer Web-based reports or analysis against large, complicated data sources
that end up as long-running SAS jobs. In doing so, one cannot expect Web users to sit idly by,
wondering when their output will arrive as the minutes tick by. This chapter provides two specific
techniques for spawning asynchronous SAS batch jobs, behind the scenes, to produce result sets.
The first technique launches the batch job, and then e-mails the result set to the user when the
batch job completes. The second technique provides the user with a status page in their browser
that is continuously updated as each batch job step completes, and then overlays the status page
with the final output when it becomes available. Both techniques are clearly described and include
easy-to-follow examples.
“Singling out specific chapters for comment is hard, because all of the chapters in this book have
significant tips, insights, and well-explained examples. It is obvious to me that there will not be
another book published about SAS/IntrNet software, because Don has covered everything there is
to say about the topic in this one great publication. But, then again, one would expect no less from
one of the original creators of SAS/IntrNet software!”
Michael A. Raithel

Westat


“The Paris Herald Tribune once published a satirical column by Art Buchwald describing a
mythical American tourist who visited Paris and ran a ‘four-minute Louvre.’ The tourist touched
all the must-see bases—the Venus de Milo, the Mona Lisa, and the Winged Victory of
Samothrace—making excellent time Buchwald wrote, ‘under perfect conditions, with a smooth
floor, excellent lighting, and no wind.’
“Superficial involvement with substance is something one can poke fun at, but it has no place in
serious matters. There is no way one could race through Don Henderson’s new book about how to
use the Application Dispatcher in SAS/IntrNet. This is material that demands close, patient, and
studious attention.
“This book reveals two characteristics of the author himself. First, he is a person who willingly
gives away his own know-how, sharing highly valuable insights with anyone who cares to listen.
Second, he is someone who is able to master advanced coding techniques easily and apply that
mastery to solving complex coding problems. Any programmer who works with SAS/IntrNet will
feel a sense of indebtedness to Don for making life easier.
“This book, which could have been subtitled Making the Most of SAS/IntrNet, makes it easy to
realize that the software has tremendous depth and is up to the job of dealing with practical coding
requirements. This shouldn’t astonish us. After all, SAS software in general has continued to
evolve and take on enhanced capabilities. Thus, to understand the Application Dispatcher, one
must make the same kind of effort that is involved in learning ODS or SAS/GRAPH, for example.
Don challenges the reader to do just that. There is no fluff here, only solid meat. Each paragraph,
each example, contains important information that a reader must digest slowly and carefully.
“This text is so educational that it really ought to become material for a new course offered by
SAS. Each chapter contains examples that could be converted easily into exercises. In any form,
Don’s masterful work will help SAS programmers to become better and stronger.”
Jim Sattler, President
Satmari Software Systems, Inc.


Don Henderson
Building Web
Applications
with SAS/IntrNet
®
A Guide to the
Application Dispatcher


The correct bibliographic citation for this manual is as follows: Henderson, Don. 2007. Building Web Applications
with SAS/IntrNet
®
: A Guide to the Application Dispatcher. Cary, NC: SAS Institute Inc.
Building Web Applications with SAS/IntrNet
®
: A Guide to the Application Dispatcher
Copyright © 2007, SAS Institute Inc., Cary, NC, USA
ISBN 978-1-59994-189-9
All rights reserved. Produced in the United States of America.
For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by any means, electronic, mechanical, photocopying, or otherwise, without the prior written permission
of the publisher, SAS Institute Inc.
For a Web download or e-book: Your use of this publication shall be governed by the terms established by the
vendor at the time you acquire this publication.
U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related
documentation by the U.S. government is subject to the Agreement with SAS Institute and the restrictions set forth in
FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987).
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
1st printing, March 2007
SAS

®
Publishing provides a complete selection of books and electronic products to help customers use SAS software
to its fullest potential. For more information about our e-books, e-learning products, CDs, and hard-copy books, visit
the SAS Publishing Web site at support.sas.com/pubs or call 1-800-727-3228.
SAS
®
and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS
Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.

Contents


Preface xi
Acknowledgments xiii

Part 1 An Introduction to SAS/IntrNet
Software
Chapter 1 Overview of SAS/IntrNet and Related
Technologies 3
1.1 Is the Application Dispatcher a Good Fit? 4
1.2 Components of SAS/IntrNet Software 5
1.2.1 The Application Dispatcher 5
1.2.2 SAS Design-Time Controls 5
1.2.3 Xplore Sample Web Application 6
1.2.4 htmSQL 6
1.2.5 SAS/CONNECT Driver for Java 6
1.2.6 SAS/SHARE Driver for JDBC 6
1.2.7 Tunnel Feature 7
1.3 Other SAS Web Components and Technologies 7

1.3.1 The Output Delivery System 7
1.3.2 The Web Publishing Tools and Related Macro Tools 8
1.3.3 SAS AppDev Studio, a SAS Applications Development
Environment 9

1.3.4 SAS
®
9 Business Intelligence Platform 9
1.4 Industry Components 12
1.4.1 Scripting Languages 12
1.4.2 Dynamic HTML 15
1.4.3 Web Services 16
1.5 Component-Based Architectures 16
1.6 Terminology 18


iv Contents
Part 2 How the SAS/IntrNet Application
Dispatcher Works
Chapter 2 Overview of the Application Dispatcher
Process Flow 23
2.1 Introduction 23
2.2 Application Broker—Application Server Process Flow 24
2.3 Process Flow Including the Load Manager 25
2.4 Performance Benefits of Using the Load Manager 27

Chapter 3 The Application Broker and the Load
Manager 31
3.1 Introduction 31
3.2 Specifying Additional HTML Output 33

3.3 Defining the Load Manager 34
3.3.1 The Load Manager Command 34

3.4 Defining the SAS Application Servers 35
3.4.1 Socket Servers 35
3.4.2 Pool Servers 37
3.4.3 Launch Servers 39
3.5 Application Broker Process Flow 40
3.5.1 Load Manager Administrative Functions 46

Chapter 4 The Application Server 47
4.1 Introduction 47
4.2 SAS Application Server Executives 49
4.3 Application Server Sessions 50
4.3.1 ODS and Sessions 50
4.4 PROC APPSRV 51
4.4.1 TCP/IP Port 51
4.4.2 Assigning Libraries 51
4.4.3 Initiating and Terminating Requests 54
4.5 Application Server Process Flow 55
4.5.1 Application Server Functions Available to the Executing
Program 60

4.5.2 Application Server Clean-Up Processing 60

Contents v

Chapter 5 Communicating with the Application
Dispatcher 63
5.1 Introduction 63

5.2 Name/Value Pairs Defined by the User’s Request 64
5.2.1 _program: The SAS Program to Execute 64
5.2.2 _service: The Application Server to Process the Request 65
5.2.3 _debug: The Output to Display 65
5.2.4 Program-Specific HTML Name/Value Pairs 68
5.3 Name/Value Pairs Defined by the Application Broker 72
5.3.1 Application Broker Administrative Fields 72
5.3.2 Environment Variables 73
5.3.3 Installation Dependent Fields 74
5.4 Name/Value Pairs Defined by the Application Server 76


Part 3 Developing Application
Dispatcher Programs
Chapter 6 Methods You Can Use to Access and
Reference Input Parameters 81
6.1 Introduction 81
6.2 Accessing Parameters as Macro Variables 82
6.2.1 Using and Referencing the Multiple Values for a Single
Parameter (the Suffix Variables) 85

6.2.2 Using the APPSRV_UNSAFE Function 87
6.3 Accessing Parameters in SCL Programs 91

Chapter 7 Various Techniques to Generate HTML 94
7.1 Introduction 94
7.1.1 The Problem with Generating Valid HTML 95
7.2 Simple PUT and FILE Statements 96
7.2.1 The generateFormTag and generateInputTag Sample
Macros 101


7.3 Extending the Output Delivery System 102
7.3.1 FORM Tags Via TITLE and FOOTNOTE Statements 102
7.3.2 Character Variables with HTML Form Text 105
7.4 SCL Submit Blocks 107
7.5 Including Static HTML from External Sources 110
7.5.1 A Macro Tool to Include External HTML 114
vi Contents
7.6 SAS Server Pages 116

7.6.1 The SAS Server Page Macro 116
7.6.2 Sample Server Page: List Libraries 118
7.6.3 A Macro to Generate Data-Driven SELECT Tags 119
7.6.4 Sample Server Page: List the Data Sets in the Selected
Library 121

7.6.5 Sample Server Page: List the Variables in the Selected Data
Set 122
7.6.6 A Macro to Generate Checkboxes for Variables in a SAS
Data Set 124
7.6.7 A Program to Page Through the Selected Data Set 125
7.7 SAS Design-Time Controls 127

Chapter 8 Creating Pages with Mixed and Alternative
Content Types 131
8.1 Introduction 131
8.2 Defining the Content Type to Be Generated 132
8.2.1 Other Headers: Selected Examples 132
8.3 Generating Pages with Other Content Types 135
8.3.1 Creating a Comma-Separated Values File 136

8.3.2 Downloading Reports and Results into Microsoft
Excel 137
8.3.3 Generating Content for Printing 138
8.3.4 Generating Multiple Output Types at Once 143
8.4 Generating Pages with Mixed Content Types: Text and
Graphics 146

8.4.1 Ensuring That the Graph Is Current 153

Chapter 9 Using REQUEST INIT and REQUEST TERM to
Specify Set-up and Shut-down
Behavior 155
9.1 Introduction 155
9.2 Specifying the REQUEST INIT and REQUEST TERM
Programs 156

9.3 Using REQUEST INIT and REQUEST TERM 156
9.3.1 Defining Libraries and Files 157
9.3.2 Overriding or Supplying Parameter Values 159
9.3.3 Standard Header and Trailer Blocks 161
9.3.4 Terminating a Request 163

Contents vii

Chapter 10 How to Create and Use Sessions 165
10.1 Introduction 165
10.2 Creating a Session 166
10.3 Saving or Restoring All Macro Variables 171
10.4 Returning to a Previous State of a Session 175
10.5 Generating Friendlier Messages for Expired Sessions 179

10.6 Extending Sessions 182
10.7 Session INIT and TERM Programs 186

Part 4 Addressing Common Application
Requirements
Chapter 11 Tools and Techniques for Debugging 191
11.1 Introduction 191
11.2 Using the _debug Parameter 192
11.3 The PROC APPSRV LOG Statement 196
11.4 Conditionally Generating Debugging Output 197
11.5 Running Application Dispatcher Programs Using SAS Display
Manager 200
11.5.1 Special Handling for SCL Programs 201

11.6 Dedicating an Application Server for Debugging 202

Chapter 12 Tips for Safeguarding Security 205
12.1 Introduction 205
12.2 The Application Server Environment 206
12.2.1 Limiting Which Application Brokers Can Access an
Application Server 206

12.2.2 Hiding Passwords 208
12.2.3 Best Practices for a Secure Application Server
Environment 211

12.3 Controlling Access to Data and Reports 212
12.3.1 Customizing Menu Choices 219
12.3.2 Using AUTH=HOST 223


viii Contents
Chapter 13 Integrating Application Dispatcher
Applications with Other Applications,
Products, and Environments 225
13.1 Introduction 225
13.2 htmSQL 226
13.2.1 Integrating htmSQL with the Application Dispatcher 228
13.2.2 Integrating the Application Dispatcher with htmSQL 230
13.3 Single Sign-On Environments 235
13.4 External Session Facilities 236

Chapter 14 Maintaining an Applications
Environment 239
14.1 Introduction 239
14.2 Supporting Development, Test, and Production
Environments and Applications 239
14.2.1 Using a Developer’s Workstation 240

14.2.2 Distinct Services 240
14.2.3 Distinct Brokers 241
14.2.4 Customized INIT Program 242
14.3 Metadata Approaches to Minimize Code Changes 244
14.3.1 The getTextString Macro 249

Part 5 Selected Examples
Chapter 15 Generating Static Versions of Dynamic
Reports 253
15.1 Introduction 253
15.2 Sample Program 254
15.3 Ensuring That Generated Links Function Correctly 256

15.4 E-mailing Static Copies of Dynamic Reports 256

Chapter 16 Simulating a Pause and Resume Capability
for the Application Server 259
16.1 Introduction 259
16.2 Sample Implementation 260
16.2.1 The Metadata Control Table 262
16.2.2 The Toggle Program 263

16.2.3 Macro to Check Status 264
16.2.4 The HTML Templates 265
16.3 Doing More with the Sample 266

Contents ix

Chapter 17 Techniques for Handling Long-Running
Processes 267
17.1 Introduction 267
17.2 Using the Cascading Style Sheets Display Attribute 268
17.3 Using the JavaScript location.replace Function 271

Chapter 18 Using Scheduled Execution to Handle
Long-Running Processes 275
18.1 Introduction 275
18.2 Sample Implementation 276
18.3 Doing More with Scheduled Execution 279

Chapter 19 Handling On-Demand Long-Running
Requests 281
19.1 Introduction 281

19.2 E-mailing Results from an On-Demand Long-Running
Process 282
19.1.1 Notifying the User 284

19.2 Updating Process Status by Refreshing the User’s Browser 285
19.2.1 Notifying the User 287
19.3 The Sample Framework—Spawning a Separate SAS Session 290
19.3.1 Sample Program to Submit a Long-Running Program—
spawnSAS.source 295

19.3.2 Sample spawnSAS Macro 298
19.3.3 Sample Long-Running Program 300
19.4 Doing More with Independent Sessions 305

Chapter 20 Using Metadata-Driven Reporting to
Construct Reports 307
20.1 Introduction 307
20.2 Sample Implementation 309
20.2.1 The Logon Template 311
20.2.2 The Logon Program 312
20.2.3 Selecting the Case or Individual to Examine 315
20.2.4 Report Components 319
20.2.5 The assembleReport Macro 323

x Contents
Chapter 21 Packaging the Application Dispatcher as a
Web Service 327
21.1 Introduction 327
21.2 Solution Architecture 329
21.3 Sample Application 330

21.3.1 The Sample .NET Client Application 331
21.3.2 The .NET Web Service 332
21.4 Using the Sample Client Application 335
21.5 Final Thoughts 338

Index 339



Preface

The rush to take mission-critical applications to the Web has changed the way companies compete
and interact. This competition has produced a lower cost-per-desktop and has extended
information access to just about anyone, whether through a Web browser, a personalized portal, or
a handheld device. Therefore, it is essential that organizations use the tools at their disposal to
their best advantage.
This book focuses on the Application Dispatcher, which is one of the components of SAS/IntrNet
software. SAS/IntrNet, and specifically the Application Dispatcher, is a mature and proven
technology for the deployment of Web solutions. However, as with most products, it has many
features and capabilities that are not fully known or exploited by users. This book discusses many
such features, thus enabling you to take better advantage of the software’s facilities and tools.
In the move to the Web, it is also important to note that applications to be deployed there must
recognize the underlying distributed nature of Web-based applications.
The native Web environment is a two-tier architecture: the Web server/Web browser tier and the
data/compute services tier. This separation means that many architectural assumptions made in
the development of applications are incompatible with the Web. The resulting issues can include
the following:
 Many Web applications are stateless (i.e., each request for compute or data services
is completely independent of the other). Thus, applications that assume exclusive
access to data are problematic (e.g., in the transaction-based world of the Web, the

concept of opening a data set for exclusive update access is not the same as in a
desktop world).
 The event model in a Web application is very different from the event model in a
desktop application. For example, if the client is a browser, the back-end compute
engine has no access to key clicks until the browser has forwarded a request for
processing to the compute server.
 A corollary to the previous point is that even if some of the logic relating to the event
model can be surfaced in the client (e.g., using Java, JavaScript, Dynamic HTML,
etc.), the separation of the client and the server can be a complicating factor in
moving existing applications to a Web environment.
While we will not explore these issues in great detail, many of the ideas and techniques presented
here will enable you to better address these requirements while building Web-based applications
using the Application Dispatcher.
Organization of This Book
This book contains five parts:
 Part 1 provides an overview of SAS/IntrNet and the role the Application Dispatcher can
play in building Web applications.
 Part 2 provides details about how the components of the Application Dispatcher work
and interact with one another.
 Part 3 discusses techniques and examples illustrating the features and capabilities of the
SAS/IntrNet Application Dispatcher. A variety of tools and best practices are provided to
xii Preface

facilitate developing applications for the Application Dispatcher. Many of these
techniques apply to the SAS
®
9 Stored Process Server as well.
 Part 4 shows how the techniques and features of the Application Dispatcher presented in
Parts 1 through 3 can be used to address common application requirements. It contains a
number of short chapters that focus on how to use the ideas discussed earlier, with a few

new techniques and methods included.
 Part 5 provides a number of examples that use the techniques, samples, and approaches
described in previous chapters and illustrates how they can be integrated to address
commonly encountered requirements. Each example describes a scenario or requirement
along with a suggested approach to implementing it using the SAS/IntrNet Application
Dispatcher.
Sample Environment
Almost all of the examples discussed in this book are available in a sample environment that is a
companion to the book. You can access it from the following URL:


The sample environment allows you to run demonstrations and most examples. Some examples
are not available for security reasons. The demonstrations and examples are organized by chapter
(i.e., you access the examples for Chapter X by clicking the link for Chapter X). The location of
each example appears in the text that describes that example. Example text is easily identified by
a Run icon in the left margin, as shown here.
The Web site also contains instructions and links to download and install the sample environment
on your local PC. By downloading and installing the sample environment locally you will be able
to do the following:
 run selected examples that are disabled on the Web site
 easily modify and experiment with the examples
 add your own data to the sample environment
 start using the samples and tools in your own SAS/IntrNet Application Dispatcher
applications

You can start out by accessing the examples from the Web site. Later, download and install the
sample environment. Thus, you can begin (and perhaps complete) reviewing the book without
having to install anything locally. Be sure to check the sample environment frequently for
updates.



Acknowledgments

Among the people I’d like to thank are the technical reviewers: Robert Allison, Vincent
DelGobbo, Paul Grant, Dana Rafiee, Michael Raithel, Warren Repole, David Shinn, Heather
Weinstein, and Bryan Wolfe.
I’d also like to thank Alan Churchill of Savian and Scott Wood of Zencos Consulting. Alan wrote
the Windows .NET sample applications discussed in Chapter 21 that illustrate packaging the
Application Dispatcher as a Web service. Scott provided the sample Java code discussed in
Section 13.4 that illustrates integration with external session facilities.
Thanks, also, to the SAS Press team who produced the book: Caroline Brickley, Patrice Cherry,
Jennifer Dilley, Shelly Goodin, Candy Farrell, Stephenie Joyner, Mary Beth Steinbach, and
Liz Villani.
I would like to thank those folks who provided feedback (and continue to provide feedback) on
the sample environment (
And finally, I would like to thank my wife, Celia Henderson, for reviewing parts of the book even
though she knows very little about SAS as well as for her patience when I would disappear for
hours and days at a time using the excuse I need to work on my book.

xiv




Part 1
An Introduction to SAS/IntrNet Software

Chapter 1 Overview of SAS/IntrNet and Related Technologies 3



SAS/IntrNet software opens SAS to the Internet, extranet, or intranet. Specifically, this software
enables users to run ad-hoc reports and dynamic applications via the Web. Broadly speaking,
SAS/IntrNet is divided into three areas:
 data services that enable the user to make SQL-type queries to the SAS server. Users can
query, update, and report data.
 compute services that give the user full access to the analytical capabilities of the SAS
server. Users can access and use any non-visual functionality provided by the SAS
server.
 out-of-the-box applications that use the SAS/IntrNet data and compute services to
deliver access to OLAP cubes created with PROC MDDB (the MDDB Report Viewer)
and to explore and report the contents of SAS catalogs and libraries (the Xplore Sample
Application).
2 Building Web Applications with SAS/IntrNet: A Guide to the Application Dispatcher


Organizations often use a diverse collection of technologies to store, manage, and report on
information. Therefore, organizations should consider factors such as the following when
choosing a technology for developing a Web-based information delivery system:
 user interface requirements
 data access and analysis requirements
 application performance
 costs of development, deployment, and maintenance
The Application Dispatcher component of SAS/IntrNet software has many facilities that can make
the applications development task easier. This book explains many of those facilities including
some that are not known to the broad population of users.
Chapter 1 gives a high-level overview of the Application Dispatcher component of SAS/IntrNet
software and places the software in context with related Web technologies.


Chapter

1
Overview of SAS/IntrNet and Related
Technologies

1.1 Is the Application Dispatcher a Good Fit? 4
1.2 Components of SAS/IntrNet Software 5
1.2.1 The Application Dispatcher 5
1.2.2 SAS Design-Time Controls 5
1.2.3 Xplore Sample Web Application 6
1.2.4 htmSQL 6
1.2.5 SAS/CONNECT Driver for Java 6
1.2.6 SAS/SHARE Driver for JDBC 6
1.2.7 Tunnel Feature 7
1.3 Other SAS Web Components and Technologies 7
1.3.1 The Output Delivery System 7
1.3.2 The Web Publishing Tools and Related Macro Tools 8
1.3.3 SAS AppDev Studio, a SAS Applications Development Environment 9
1.3.4 SAS
®
9 Business Intelligence Platform 9
1.4 Industry Components 12
1.4.1 Scripting Languages 12
1.4.2 Dynamic HTML 15
1.4.3 Web Services 16
1.5 Component-Based Architectures 16
1.6 Terminology 18

4 Building Web Applications with SAS/IntrNet: A Guide to the Application Dispatcher



1.1 Is the Application Dispatcher a Good Fit?
One of the primary design goals for the SAS/IntrNet Application Dispatcher was to mask the
complexity of other technologies, such as CGI and HTML, which are needed to implement SAS
Web technologies.
The Application Dispatcher enables organizations to deploy a Web application without requiring
the development staff to have extensive knowledge of CGI or HTML. The advent of ODS makes
this even easier. Of course, some knowledge of these technologies is advantageous in
implementing a Web solution. However, the application and the data usage factors should be the
driving force behind determining which technologies to use.
There are many different factors and criteria that should be considered when deciding which
components are most appropriate for a given set of development needs. In addition to the
requirements and the skills available for the current application, other Web-based applications and
skills available within the organization should be considered. Applications that meet the following
criteria are likely to be good candidates for the Application Dispatcher:
 Existing SAS programs produce output and reports that should be made available to some
or all users in an organization over the Web.
 The application is an extension of existing SAS applications.
 The reports are generated from dynamic data. Note that if data is reasonably static (e.g.,
only change monthly), then Web publishing the data via ODS might suffice to meet the
application needs.
 Users need the ability to customize the reports (e.g., select specific subsets) to get the
output they need.
 The development staff has a broad range of SAS programming skills. If there is only
limited knowledge of or experience with CGI, HTML, Java, etc., then the Application
Dispatcher with ODS would be a good choice.
 SAS programming expertise is available and the timeframe to deploy is a critical factor
(i.e., time to train the staff in new technologies is not available).
 The application will be run on-demand to deliver specific reports.
 The data is maintained centrally (e.g., in a data mart or data warehouse). Data which is
inherently local or specific to a particular user is typically not a good candidate for

application or report distribution.
 The data files are potentially large and the reporting process reduces the size of the data
(i.e., downloading a final customized report as HTML, PDF, or RTF is much faster than
downloading the data for the user to process locally).
 The data already exists (or is accessible) as SAS data sets.
 There is a need to reduce paper reports by allowing users to access customized reports
that meet their specific requirements.
Chapter 1: Overview of SAS/IntrNet and Related Technologies 5



1.2 Components of SAS/IntrNet Software
SAS/IntrNet contains a variety of components that can be used individually or in combination to
address specific needs of a Web-enabled information delivery solution. If multiple components
are used, each component provides services that best meet the requirements. The power of
SAS/IntrNet lies in the remarkable range of its components. They are discussed in the following
subsections.
For more information about terminology, refer to Section 1.6.
1.2.1 The Application Dispatcher
The Application Dispatcher has two required components: the Application Server and the
Application Broker. It provides both compute (i.e., running a SAS program) and data services
(i.e., running a SAS program that does a SQL query using PROC SQL). It also includes out-of-
the-box applications (e.g., Xplore). The Application Server and the Application Broker are
discussed in detail in Chapters 3 and 4.
The Application Dispatcher provides a CGI gateway (namely, the Application Broker) between a
Web browser and SAS. This gateway lets programmers build dynamic applications that can
access the power of SAS (the Application Server) from a Web browser. The gateway also
provides the capability to run any SAS program that can be executed in batch mode. The
programmers need to work only with the details of what results (e.g., reports) the SAS program is
to generate. All of the details relating to CGI (e.g., communicating the parameter values from the

HTML page and returning the results to the user’s Web browser) are handled by the Application
Broker and require no knowledge of CGI development or programming. The Application Broker
passes all incoming requests to the Application Server, which can execute almost any batch SAS
program. The Application Dispatcher allows the deployment of SAS programs to multiple users
(whether or not they have SAS installed on their machines).
The SAS/IntrNet Application Dispatcher also includes an optional Load Manager that can be used
to intelligently route and handle a large volume of incoming requests. Based on its configuration,
the Load Manager can start and stop remote Application Servers based on demand, and route
requests across multiple back-end application servers, regardless of the operating environment.
The Application Broker, Load Manager, and Application Server are described in more detail in
Chapters 3 and 4.
1.2.2 SAS Design-Time Controls
SAS Design-Time Controls (DTCs) make it easy to create SAS/IntrNet applications without prior
knowledge of HTML or SAS programming. DTCs are add-in components for What You See Is
What You Get (WYSIWYG) HTML editors that support the SAS Design-Time Controls standard
defined by Microsoft, including Microsoft FrontPage, Macromedia Drumbeat 2000, SoftQuad
HoTMetaL PRO 5, webAF, and more. DTCs are ActiveX controls that run inside the HTML
editor and generate text based on the user’s input. In this way, a favorite visual HTML editor can
be used to build SAS/IntrNet reports and applications via a point-and-click interface.
With SAS DTCs, static reports can be created and published to a Web server. Dynamic reports
can be created using JSP and ASP technologies, retrieving and displaying the latest information
when a user selects the page from the Web browser. Both static and dynamic DTC reports can be
6 Building Web Applications with SAS/IntrNet: A Guide to the Application Dispatcher


viewed by any browser (e.g., Internet Explorer, Netscape, Firefox, etc.). Using the DTCs does not
require any prior experience with developing ASP or JSP pages.
1.2.3 Xplore Sample Web Application
SAS/IntrNet includes a sample application called Xplore which exposes the SAS data
environment to the Web. Using the Application Dispatcher, Xplore can dynamically access a

variety of SAS data and file types for reporting, generating graphics, and performing drill-down
analysis on the Web. The Xplore sample application is shipped with the SAS source and can
provide a valuable resource of techniques and tools.
1.2.4 htmSQL
htmSQL is a CGI gateway to SAS and provides data services that, in turn, provide access to SAS
data from a Web browser, enabling the building of dynamic SQL queries. htmSQL consists of a
CGI program that resides on the Web server and can be used to access and update a SAS data set
(including Read access through views to an external DBMS). The developer provides an input
file, e.g., a .hsql file (note that the extension does not have to be hsql), containing SQL statements
embedded in HTML, and htmSQL submits the statements to a SAS data server (either
SAS/SHARE or the SAS Scalable Performance Data Server). htmSQL retrieves and formats the
results according to the HTML embedded in the .hsql file. htmSQL can be used to create
sophisticated, dynamic applications that let users manipulate data to address their specific
information requirements. htmSQL can also be used to generate any other type of markup
language such as Extensible Markup Language (XML), Compact HTML (cHTML), Handheld
Device Markup Language (HDML), and Wireless Markup Language (WML).
1.2.5 SAS/CONNECT Driver for Java
The SAS/CONNECT driver for Java provides compute services. It is a set of Java classes that can
be used to create Java applets, JSP, and Java applications that communicate with SAS software on
a server, thus taking advantage of remote SAS computing resources. The driver provides
functionality that is similar to what a SAS client can do with SAS/CONNECT, except that the
functionality is available to any Java program and does not require SAS to be locally installed.
Programs that use the SAS/CONNECT driver for Java can start a SAS session, connect to that
session, create data sets, access existing SAS data, run SAS programs to analyze SAS data, and
retrieve the results. The Java components in SAS AppDev Studio can be used to create
applications that use the SAS/CONNECT driver for Java without requiring extensive knowledge
of Java.
1.2.6 SAS/SHARE Driver for JDBC
The SAS/SHARE driver for Java Database Connectivity (JDBC) provides data services and is a
set of Java classes that can be used to create Java applets, JSP, and Java applications that

communicate with a SAS data server (either SAS/SHARE or the SAS Scalable Performance Data
Server) via SQL queries. The Java programs can let a user view and update data by submitting
SQL queries and statements through a direct connection to the SAS server. The Java components
in SAS AppDev Studio can be used to create applications that use the SAS/SHARE driver for
JDBC without requiring extensive knowledge of Java.
Chapter 1: Overview of SAS/IntrNet and Related Technologies 7



1.2.7 Tunnel Feature
The SAS/IntrNet tunnel feature employs HTTP tunneling to allow Java applets to communicate
with remote systems via a CGI program running on the Web server. As a security measure, Java
specifications dictate that an applet cannot make network connections to a machine other than the
machine from which it was downloaded, unless Java 2 (or later) is being used and explicitly
allows this. When deploying Java applets, this security measure might force the use of a server
configuration that is less than ideal, because that server would have to be installed on the same
machine as the Web server. In addition, many firewalls prohibit applets from communicating
beyond the firewall, a restriction that can further reduce server configuration options. The tunnel
feature addresses both of these configuration problems.
The tunnel feature, with Java applets written using the Java components in SAS/IntrNet or the
Java components in SAS AppDev Studio, can be used to eliminate the restriction on where the
SAS server runs in relation to a Web server and firewall. JSP applications do not have any of
these restrictions because they run as native operating environment applications and have access
to all resources.
1.3 Other SAS Web Components and Technologies
Other SAS resources provide facilities and tools that provide critical capabilities for any Web
application that is based on SAS. Selected resources are briefly described in this section.
1.3.1 The Output Delivery System
Starting with Version 7 of SAS, the Output Delivery System (ODS), which is part of Base SAS
software, allows the direct creation of Internet content, including HTML files. In general, ODS is

a method of delivering output in a variety of formats and of making the formatted output easy to
access. Instead of taking the output from a procedure and creating HTML via post-processing,
ODS creates the HTML during the initial creation of the procedure output. This method is more
efficient and provides many new possibilities for report layout. Through the addition of a few
simple lines of code, developers can convert a standard program into one that creates HTML
output. It’s not necessary to know HTML or modify existing SAS code.
In addition to HTML, ODS supports many other types of output formats, including Adobe
Acrobat Portable Document Format (PDF), Rich Text Format (RTF) for use in Microsoft Word
and other word processing programs, CSV for use by Microsoft Excel and other spreadsheet tools,
XML, and WML for use with WAP-enabled hand-held devices. ODS also produces GIF-, JPEG-,
ActiveX- and Java-based graphics in conjunction with SAS/GRAPH software. This capability lets
developers create a wide variety of content that can be delivered over the Web with little or no
extra effort. Consider the following example that uses ODS to produce the desired output and
automatically passes the results back to the user’s browser:
ODS HTML BODY=_webout;
proc print data=sashelp.class;
run;
ODS HTML CLOSE;

ODS, which is the subject of a number of papers and SAS Press books, should be the default
mechanism for producing the Internet content output required of most Web applications.
8 Building Web Applications with SAS/IntrNet: A Guide to the Application Dispatcher


1.3.2 The Web Publishing Tools and Related Macro Tools
For users running SAS Version 6 and later, the Web publishing tools are a collection of tools that
generate Internet content output. While these tools continue to exist in SAS software, the tasks
they perform are usually easier to accomplish with ODS. However, there are occasions where
their use might be a better fit. Also note that these tools are not part of SAS/IntrNet and may be
used in any SAS program.

The Web publishing tools include the following:
 The HTML formatting tools, included with Base SAS software, are a collection of
macros that format SAS data sets and procedure output into HTML pages that can be
shared with Web users:
 The Output Formatter (%out2htm), which reformats output from any SAS
procedure as an HTML file.
 The Data Set Formatter (%ds2htm), which displays SAS data sets as HTML 3.x
tables. The Data Set Formatter supports WHERE clauses, BY-group processing, and
other data presentation capabilities.
 The Tabulate Formatter (%tab2htm), which reformats the output from the
TABULATE procedure into HTML 3.x tables.
 Thin-client graphics are part of SAS/GRAPH software and are specialized, lightweight,
visual Java applets or ActiveX controls which do not establish a persistent connection to
a server. Instead, they receive all the information they need from applet parameters. The
following tools generate the applet and ActiveX HTML calls along with the custom data
values that are used as input to the visual component:
 The GraphApplet HTML Generator (%ds2graf) produces graphs and charts from
SAS data. It generates HTML that uses the GraphApplet or SAS/GRAPH Control for
ActiveX to display and manipulate the graphics.
 The MetaView HTML Generator (%meta2htm) produces an HTML file that
includes metadata through which users can view SAS/GRAPH output in a Java
applet. To view the output as graphics, you must use the MetaViewApplet.
 The RangeView HTML Generator (%ds2csf) produces an HTML file that
displays a critical success factor (CSF) from a SAS data set using the
RangeViewApplet.
 The TreeView HTML Generator (%ds2tree) produces an HTML file that displays
a hierarchical tree from a SAS data set using the TreeViewApplet.
 The Constellation Chart HTML Generator (ds2const) produces an HTML file
that displays data from a SAS data set as a constellation chart using the
ConstellationChartApplet.

×