Experiences with SAS software and the Internet at Volvo Data.

advertisement
Experiences with SAS software and the Internet
at Volvo Data.
Katarina Floberg, Volvo Data Corporation
Johan Jerresand, Niklas Data Group
Introduction
The use of public Internet and internal Intranets to make information available for
larger groups of people are growing rapidly. Factors as ease of use and ability to
provide a standard interface are important explanations to the big popularity. For
system developers this leads to an increasing need of knowledge about how the Web
technologies can be combined with other products, to support access of data and
analysis done with these products.
We have studied and tested different possibilities to integrate the SAS System and
Web technology. The problem areas covered are accessing SAS data from a Web
browser, running SAS programs and analysis from a Web browser and producing
Web pages using SAS. We have taken a closer look at some of the techniques
available, both when it comes to setting up the environment and to make an
implementation of a small Web solution using these different techniques.
These are the techniques we will take a closer look at in the presentation :
• Using HTML macros and graph drivers for data visualization on the Web.
• Using JDBC classes/Java applets to access SAS data from a Web server.
• Setting up a HTTP/ODBC server on a NT server for producing online reports over
the Web.
• Using CGI to let a server control the execution of predefined SAS programs.
None of the techniques above needs to have SAS on the client. What is required is a
Web browser like Netscape Navigator or Microsoft Explorer. Problems and details to
think about when configuring the system will be discussed in the presentation.
The different platforms used in our tests are Windows 3.x, Windows 95, Windows NT
3.5, Windows NT 4.0, Sun Solaris 2.5 and MVS. The different platforms have been
used in combination with the different techniques depending on what is available on
the platforms.
1
Volvo Data Corporation
The Volvo Group have companies that produce and sell cars, trucks, buses,
construction equipment, marine engines and aircraft engines. The Volvo Group
employs around 70 000 people.
Volvo Data Corporation is the Volvo Group center for IT-competence. Our head
office is situated in Göteborg, Sweden. We also have Swedish offices in Eskilstuna,
Köping, Olofström and Skövde, and subsidiaries in Belgium, USA, Great Britain and
Switzerland. Volvo Data Corporation employs just over 1100 people.
Niklas Data Group
Niklas Data Group has for the last 10 years been 100% focused on supplying tailor
made business solutions for our clients, using the SAS System. Our business idea, to
be the leading SAS Quality Partner in Europe, has been very successful and Niklas
Data Group is a rapidly growing organisation with more than 100 dedicated SAS
consultants.
A key issue for success is understanding the conditions under which our clients
operate. We therefore have a business oriented organisation split into five main
sectors:
•
•
•
•
•
Manufacturing and pharmaceuticals
Banking and insurance
Trade and service
Public sector
Telecommunications
Niklas Data’s current business solutions fall into four major categories:
•
•
•
•
Data warehousing
Data mining
IT service
Systems integration
To fully utilize prior experience as well as stay in the forefront in our field, we
maintain internal competence developments teams in each of these areas.
Our long term commitment to quality has been recognized by both our clients and
SAS Institute. We were certified as one of the first SAS Quality Partners in 1994 and
we are a charter member of SAS Institute’s Rapid Warehousing Program (initiated in
1995).
2
In the increasingly international business environment of today our work becomes
even more global. Many of our clients are large multinational corporations with the
need for business partners that can support them independent from national
boundaries.
Our European headquarters is located in Amsterdam and we currently have offices in
Sweden (3), Norway and Finland. With this geographical spread, Niklas Data is
within a couple of hours from any of our customers in Europe. There are several new
offices planned currently for other countries in Europe.
3
Using HTML macros and graph drivers for data visualization on the Web
The Web is the ideal tool for a company when it comes to making information
available for large groups of people, both inside and outside the company. Regularly
generated text reports, graphic reports and data tables are examples of information that
often are distributed to many people inside a company. One convenient way to handle
the distribution is to create Web pages and display them on an Intranet at the
company.
Pages used on the Web have to be created in specific formats. For text documents this
is done by a language called HTML (hypertext markup language), and for pictures the
formats GIF (Graphics Interchange Format) and JPEG are used.
To display SAS data and reports created by SAS on the Web, the data and the text
reports have to be converted to HTML pages and the graphic reports have to be
converted to GIF or JPEG format. This could be done quit easily within the SAS
System.
The new SAS/IntrNet Software (beta-release) includes HTML formatting tools that
generate HTML-formatted output from SAS procedure output, SAS data sets and log
window output. It also includes graph drivers that generate graphic output in GIF or
JPEG formats from SAS/GRAPH procedures.
HTML formatting tools are an output formatter that saves the output from any SAS
procedure to an HTML file, and a data set formatter that converts SAS data sets to
HTML 3.x tables. These HTML formatting tools are written as SAS macros and can
be incorporated into existing SAS code. They can also be used from an interactive
SAS/AF Frame interface, that are available in release 6.12. It is of course also possible
(and not so difficult) to write your own SAS macros that create HTML code.
Example:
libname DATA ‘..\sas internet data’ ;
%HTMLTAB( data=DATA.STDTABLE,
outfile='..\sas internet tables\TMDTABLE.HTM',
vars=MARKET TYMTMD DIFMTMD TYATMD DIFATMD,
tattrib=border width=100%,
colspec=width=20%,
title=Total Registrations Standard Table,
hhead=Total Registrations ) ;
4
Graph drivers are GIF, IMGGIF and IMGJPEG and they are easy to use. The file
where the graph should be stored is specified in a filename statement, and the graph
device is specified in a GOPTION statement. The GIF driver is the one that offers
most functionality. Both GIF and IMGGIF are available in 6.09E and can be used
when creating graphics on a mainframe.
Example:
goptions gsfname = GIFFILE gsfmode = replace device = gif570 vsize = 4.1 ftext = swiss ;
filename GIFFILE '..\sas internet graphs\TMDGRAPH.GIF' ;
libname DATA ‘..\sas internet data’ ;
pattern1 value = X3 color = green ;
pattern2 value = solid color = red;
axis1 value = none
label = none ;
axis2 label = ( j=c "CARS" )
origin = ( 16 pct ) ;
axis3 label = ( j=c "%" )
origin = ( 16 pct ) ;
axis4 order = ( &MORDER1 &MORDER2 )
label = none ;
legend1 shape = bar( 6, 0.6 )
across = 2
label = none
frame ;
title f = swiss "Total Market Development &FMLNAME - &TMLNAME" ;
proc gchart data = STDGRAPH ;
hbar YEAR / sumvar = TMDVALUE
group = MARKET
subgroup = YEAR
discrete
legend = legend1
frame
maxis = axis1
raxis = axis2
gaxis = axis4
gspace = 0.2
space = 0
nostat ;
run ;
quit ;
5
Using JDBC classes/Java applets to access SAS data from a Web server
SUN Microsystems provide a standard interface for communication between Java
Applets and databases called JDBC (Java Database Connectivity). SAS Institute has
implemented a JDBC driver to comply with the JDBC API specification. This driver
will provide direct access to remote SAS data through a SAS/SHARE*Net Server.
Other external databases like DB2, ORACLE, Rdb, Informix etc. can be accessed this
way if you have SAS/ACCESS installed at your site.
This JDBC driver consists of a set of JDBC classes which make it possible to access
remote SAS data without having any SAS Installation on the local computer. SAS
Institute also provides a set of Java sample classes as well as templates you can use
when writing your own Java applets with functionality towards the SAS data.
Requirements accessing remote SAS data over the Internet using SAS JDBC drivers:
Client :
•
•
Java Enabled Browser (Microsoft Explorer 3.0, Netscape Navigator 3.0 etc).
SUN Java Core classes for JDBC available through an environment variable
Classpath.
Server :
•
•
•
The SAS System at the server side with both SAS/SHARE and SAS/SHARE*Net.
SAS JDBC classes for remote data access over the Internet.
Java Applets using the SAS JDBC classes implementing some kind of
functionality.
Installation process. In this example Windows 95 (Client) / Windows NT (Server):
Client:
1. Add an environment variable named Classpath referring to the Java directory
holding the Sun Java Core classes which can be downloaded from SAS Institutes
Web Site.
Example:
If the Java directory is stored like this (Windows) g:\data\java\sql\… then add a line,
set classpath=g:\data to your autoexec.bat.
2. Install a Java Enabled Web Browser.
3. If no domain name server is available add a line to your hosts file.
Example:
193.193.193.1
www.sasinet.com
# IP address and alias used in the HTML documents.
6
Server:
1. Install a Web server.
2. Add a line to the Windows NT directory\system32\drivers\etc\services
file.
Example:
sasiserv
5000/tcp
# Name reference and port number for a
service used by the SAS/Share Server.
3. Install the SAS System for NT Server.
4. Start a SAS/SHARE Server with the libname you want to be able to access.
Example:
libname data ‘..\sas internet data’;
/* Sasiserv is the name referring to the port defined in the services file in step 2. */
Proc server serverid = sasiserv;
run;
5. Extract the directory structure in the jdbc.zip file, available from SAS Institute’s
Web site, to a directory that the Web server can access.
6. In the HTML page on the Web server that refers to an applet that uses the
SAS/JDBC classes edit the HTML page so that it refers to the JDBC classes that
you extracted in step 5.
Example:
<APPLET
<PARAM
<PARAM
<PARAM
<PARAM
<PARAM
code="COM.sas.sharenet.samples.GenericJDBC.class"
width=600
height=360>
name=title
value="New Car Registrations">
name=url value="jdbc:sharenet://www.sasinet.com:5000">
name=columns value="3">
name=rows value="4">
name="select" value="select * from data.regdata">
</APPLET>
7
Setting up a HTTP/ODBC server on a NT server for producing Online reports
over the Web
Several Web Server vendors have written programs that use Microsoft’s ODBC
(Open Database Connectivity) interface to retrieve and update information from
databases dynamically. These gateways make it possible to connect to all database
systems that have implemented an ODBC driver for their DBMS. SAS Institute
provides such a driver and therefore it is possible to access SAS data over the Internet
without actually having the SAS System at the client computer.
Requirements for accessing remote SAS data over the Internet using SAS ODBC
drivers:
Client :
•
Web Browser.
Server :
•
•
•
The SAS System at the server side with both SAS/SHARE and SAS/SHARE*Net.
ODBC gateway program, like IDC (Internet Database Connector).
SAS ODBC driver.
To let your Web application access your SAS data sources in the case using ODBC,
you have to define a set of documents giving access to the SAS data.
These are the documents that need to be created when implementing a HTTP/ODBC
application:
8
1. Define an IDC (Internet Database Connector) document.
An IDC document consists of an SQL query and a set of parameters giving
information about where to send the query and how to take care of the result.
The following parameters are required
Datasource:
The name of a Data Source defined in ODBC manager. It should
be a system datasource letting external users connect to the
datasource.
Template:
The name of a HTX document. This is a HTML template
document updating dynamically depending on the result of the
query submitted from the IDC document.
SQL Statement:
The SQL query to be submitted. The IDC documents SQL
statement can include parameters sent with the URL.
IDC document example:
Datasource:
newreg
Template:
marea.htx
SQLStatement:
+SELECT distinct year, marea, areasort,
+
sum(tyavalue) as tyasum,
+
sum(lyavalue) as lyasum,
+
put(100*sum(tyavalue-lyavalue)/sum(lyavalue),8.2) as diff,
+
sign(input(calculated diff,8.)) as sign
+FROM data.regdata
+WHERE cartotal eq 'Volvo'
+ and (put(year,4.) eq '%year%' or '%year%' eq 'All')
+GROUP by marea, year
+ORDER by areasort, year
2. Define a HTX document.
The HTX document holds the HTML code used to present the result received from the
SQL statement specified in the IDC document. What is special with the HTX
document compared to an ordinary HTML document is that you can create HTML
code dynamically. Code within <% ….. %> makes it possible to add logic statements
and to read parameters from the IDC document which launches the HTX document.
Below is an example presenting the information received from the IDC document
example above.
9
HTX document example:
<html>
<title> Click on a Market Area </title>
<body bgcolor="C0C0C0">
<center>
<img src="/Volvo/Images/Sas.gif">
<h2>Click on a Market Area to see all Markets in the area. </h2>
<p><p>
<table border>
<tr>
<th><font color=blue><b>Market Area</b></font></th>
<th><font color=blue><b>Year
</b></font></th>
<th><font color=blue><b>Acc. This Year
</b></font></th>
<th><font color=blue><b>Acc. Last Year
</b></font></th>
<th><font color=blue><b>Diff %
</b></font></th>
</tr>
<%BeginDetail%>
<tr>
<td>
<a href="/scripts/market.idc?year=<%year%>&marea=<%marea%>"> <%marea%></a>
</td>
<td align=right> <%year%> </td>
<td align=right> <%tyasum%> </td>
<td align=right> <%lyasum%> </td>
<%If sign gt "0" %>
<td align=right><font color=green> <%diff%> </font></td>
<%else%>
<td align=right><font color=red> <%diff%> </font></td>
<%EndIf%>
</tr>
<%EndDetail%>
</table>
</font>
<form action="/scripts/marea.idc" method=get>
<br>
Select a Year: <select name="Year">
<option value="All">All
<option>1996
<option>1995
<option>1994
<option>1993
<option>1992
</select><br>
<br>
<input type="submit" value="Update Table">
</form>
</center>
<hr>
</body>
</font>
</html>
10
Using CGI to let a server control the execution of predefined SAS programs
The next step is to access a SAS session on a server and run predefined SAS programs
from a Web browser. To do this it is necessary to have a CGI program that takes care
of the exchange of information between the Web browser and the SAS session. CGI
(Common Gateway Interface) is a standard interface for running external programs
under HTTP servers. CGI programs can be written using for example Pearl which is
free software for UNIX and Windows NT.
Installing CGI software and writing CGI programs can be complicated and requires
extensive knowledge in the language used. But there is an easier way. Instead of
creating your own CGI programs, it is now possible to use the CGI Application
Dispatcher in SAS/IntrNet Software, available in release 6.12. The Application
Dispatcher includes an Application Broker and an Application Server. The
Application Broker is a CGI program written in C. It should be installed on the Web
server, in the directory with CGI scripts. The Application Server is an SCL program.
It is possible to use more than one server. The broker and the server communicate
over a TCP/IP socket that should be defined in a configuration file.
The interface to the Web for the user is an HTML page. Variable values are passed
from the Web page to the SAS session by the broker that creates macro variables from
the HTML input type. A program is then executed in the SAS session. The program
generates results in for example HTML, GIF or JPEG format. There results are then
passed back to the Web browser by the broker. The program used can be a SAS
program, a source entry, an SCL entry or a compiled macro.
An application that is built on the functionality described above is the MDDB Report
Viewer. It is used from a Web browser to look at reports and graphs generated on data
stored in a MDDB (multidimensional database).
Requirements running SAS programs over the Internet using CGI:
Client :
•
Web Browser.
Server :
•
•
The SAS System at the server side with an application server.
The Application Broker.
11
HTML document example:
<HTML>
<HEAD>
<TITLE>Adhoc Graph</TITLE>
</HEAD>
<body text="#00000" bgcolor="#FFFFFF" link="#0000FF" vlink="#551A8B" alink="#FF0000">
<FORM ACTION="/scripts/sasdemo/broker/broker.exe"> <!-- Change this line for your site -->
<INPUT TYPE="HIDDEN" NAME="_PROGRAM" VALUE="pgm.qgraph.sas">
<center>
<H1>Adhoc Query Graph</H1>
<HR>
<H2>Select a market, car and year for your graph</H2>
<INPUT TYPE="HIDDEN" NAME="_service" VALUE="default">
<NOBR>
Market: <SELECT NAME="market">
<option value="S" selected>Sweden
<option value="N"> Norway
<option value="SF"> Finland
<option value="DK"> Denmark
</SELECT>
</NOBR>
Car: <SELECT NAME="car">
<option selected>965
<option>964
<option>945
<option>944
<option>855
<option>854
</SELECT>
Year: <SELECT NAME="year">
<OPTION selected> 1996
<OPTION> 1995
<OPTION> 1994
<OPTION> 1993
<OPTION> 1992
</SELECT>
<HR>
<INPUT TYPE="SUBMIT" VALUE="Create Graph">
</FORM>
</BODY>
</HTML>
12
SAS program example:
data TEMP1( keep = MARKET CAR YEAR CMONTH TYAVALUE ) ;
set DATA.REGDATA ;
where MKTCODE = "&MARKET" and CAR = "&CAR" and YEAR = &YEAR ;
CMONTH = put( MONTH, z2. ) ;
run ;
options fmtsearch = (DATA) ;
goptions gsfname=QGFILE gsfmode=replace dev=gif570 vsize=4.1 ftext=swiss
gunit=pct htext=1.8 ;
filename QGFILE '..\sas internet graphs\qgraph.gif' ;
pattern1 value=solid color=red ;
title1 h=5.0 'Accumulated Registrations' ;
title2 h=5.0 "&MNAME &CAR &YEAR" ;
proc gchart data = TEMP1 ;
block CMONTH / sumvar = TYAVALUE
noheading ;
run ;
quit ;
data _null_;
file _webout;
put 'Content-type: text/html';
put ;
put '<HTML>';
put '<HEAD><TITLE>Query Graph</TITLE></HEAD>';
put '<body text="#00000" bgcolor="#FFFFFF" link="#0000FF" vlink="#551A8B"
alink="#FF0000">';
put '<br>';
put '<br>';
put '<center>';
put '<img src=/sasdemo/adhoc/qgraph.gif>';
put '</BODY>';
put '</HTML>';
run;
13
Conclusion
By using the techniques mentioned above users can access information stored in your
Data Warehouse without having to install a lot of Software products on the local PC
or Workstation. Providing information in a centralized way like this also makes it
easier to handle updates of the systems you implement.
Using these new technologies combined with the basic functionality within the SAS
System gives you an opportunity to make your old SAS implementations accessible
for a large number of people without having to install SAS on each client computer.
This way you can also give a large number of users some basic functionality when it
comes to accessing information stored in your Data Warehouse solutions, without
having to pay a fortune for client software installations.
Much of the functionality is now available for users to create reports interactively with
Java/JDBC, ODBC/HTTP, Application Dispatcher etc. There are still though many
users that just want to view some kind of standard report updated on a regular basis.
The basic functionality within the SAS System and the different techniques described
in this paper let you create solutions that satisfy both types of users.
The different techniques described in this paper offer advantages and disadvantages.
For example ODBC/HTTP can only be used with Microsoft Information Server, but it
makes it possible to create flexible reports quite easily if you have good HTML
knowledge.
Java/JDBC will give you platform independent access to your SAS data, but you need
good knowledge in the Java language and it requires extensive programming.
Using the SAS Application Dispatcher and Web formatting tools provided by SAS
Institute you can create new and access old SAS solutions from your server platform
and place them on the Web. In this case the processing of the application will be on
the server side and not on the client side as if you are using a Java/JDBC solution.
We don’t think that one of these techniques will solve all your business problems. But
by combining them you have the chance to meet the needs for your business when it
comes to IT software solutions.
14
Download