Professional Documents
Culture Documents
DP Using Sas Mysql and
DP Using Sas Mysql and
DP Using Sas Mysql and
solutions that do not include the specific The aim for stage one was to design a
features that we need. simple interface for end-users to interact
with. Apache, MySQL and PHP are
For example, PHP was designed widely available and widely used for this
specifically to create dynamic database purpose. All three are open source
driven web applications such as the one projects, meaning that there are no direct
used in Stage One, and SAS has fiscal costs for the licensing or use of the
advanced capabilities to deliver reports software.
and statistical analysis. By using our
setup we are able to avoid building All three software products can be found
custom reports in PHP or designing a on the Internet and include full
web application with SAS, either of which instructions for installation. We
would be an enormous headache. recommend reading all documentation
and installation instructions carefully
3.2 Survey Data Tables in MySQL before attempting to install or setup any
of these software packages. Any
problems encountered can usually be
We needed to redesign our database to solved by using your favorite search
complete this project. We started with a engine (e.g., Google).
table representing the result set from
each survey administered. Each table Apache is a web server and is the silent
followed a slightly different format with partner in the entire operation. Apache’s
differing field names and Dynamic Web- primary job is to monitor all web activity
based Reports Using SAS 3 types. and send requests back and forth
through the Internet.
We decided to alter the structure of each
table creating two fields (a numeric field
and a character field) for each field that 4.1 HTML Forms
previously existed to take advantage of The fundamental idea of the Input
the full capabilities of SAS. Collection stage is to allow the end-user
to choose options from a website and
We also decided on a naming convention then send those inputs to SAS. We
to standardize all tables. Then we needed to use HTML forms to do this.
developed two tables for use in the Input
Collection phase. The first table is a The form object is a collection of HTML
simple list of surveys that the end-user is elements that allow the end-user to
allowed to choose from together with submit or input information which can
some other data about each survey. then be processed by client or server
The second table warehouses the text for based applications. Below are examples
each survey question asked along with of form definitions.
an identifier that corresponds to the field
<form name="AName" method="GET"
names from each survey table. This action="web address">
allows us to only display question text insert sub-elements here
and to tell SAS in what fields we are </form>
interested.
4. Input Collection (Stage 1) or
<form name="AName" method="POST"
action="web address">
Using SAS, MySQL, and PHP to Empower 4
Here is an example of a SAS program Next we close ods listing and open
that will run when called by the ods html. Here we send the body to
Application Dispatcher. Any SAS _webout which means the output will get
program that can be called on the sent to the end-user's browser. Use
command line can be executed by dynamic title="" to set the text in
broker.exe, as we mentioned earlier. the title bar. Output style can be altered
using the style command. SAS has
We begin by using a libname statement several predefined styles to use, a
to create a library to the database holding custom style can be created using proc
all of our survey data. Next, we create a template.
temporary table using proc sql into the
work library. You can also link to an external style
Notice that we use the variable &survey sheet to change the look of your output.
which is sent through GET/POST as The title statement adds a title on
specifying the data requested by the end- your output, as opposed to the title in the
user. title
bar of the end-user's browser. Then we
libname SURVEYS mysql use proc tabulate to display our
user='user' password='pswd' results.
database='dbname'
server='ip' port=3306;
run; Notice that we have two variables in use,
&options and &question. These refer
proc sql; to two questions chosen by the end-user.
create table work.my_survey as Both show up in this case because as
select * from SURVEYS.&survey; class variables they happen to have
run; character data in them.
ods listing close;
Since we want the character data to
ods html body=_webout show up in the results we have defined a
separate column in each of our data
Using SAS, MySQL, and PHP to Empower 7
tables called dummyN. This column is all descriptive report for the survey data that
1's and only serves the purpose of giving we warehouse.
us a numeric column to work with for the
var statement. It would be as simple to create a web
interface for analytic reports. In this case,
We close with ods html and re-open just replace proc tabulate with proc
ods listing at the end of the program. glm or any other analytic procedure that
At this point the SAS program is finished SAS provides.
and the results are displayed to the end-
user's browser window. Contact Information
6. Conclusions Jeremy Morris
University of Utah
This paper demonstrates and documents Office of Budget & Institutional Analysis
how we integrated the LAMP architecture 110 Park Building
with the power of SAS to create dynamic 201 S. Presidents Circle
end-user driven web application that Salt Lake City UT 84112
produces reports containing any SAS
output. jeremydmorris@gmail.co