nesug 16 graphics and information visualizationgraphics ... · this is one of the beauties of...

10
Enterprise Guide – A Code-Free Approach to Data Analysis and Reporting Rachel Jiang and Ed Heaton, Westat, Rockville, MD ABSTRACT Do you yearn for a code-free approach to data analysis and reporting? Would you like a little help when you need to code procedures that you seldom use? If your answer is "Yes" to either of these questions then SAS ® Enterprise Guide ® may be the tool for you. This paper will present SAS Enterprise Guide, a powerful Windows client application. Enterprise Guide is a useful, project-oriented tool that allows you to analyze your data quickly. With a straightforward interface, it helps you accomplish dozens of analytical and reporting tasks with little knowledge of SAS programming. This application enables users with transparent access to both SAS and other types of data. Interactive task windows lead users through analyses and summaries, producing high quality SAS graphics. The results can be exported to other Windows applications and the Web. The ability to schedule a project to run later enables users to refresh and distribute reports automatically at regular intervals. The authors will demonstrate some of the features of Enterprise Guide through a lifelike project. WHAT IS ENTERPRISE GUIDE? SAS Enterprise Guide is an application that SAS developed as a point-and-click software in order for non- SAS programmers to analyze data without mastering SAS programming skills. Meanwhile, it can also assist SAS programmers to develop SAS code by pointing and clicking inside the application. It has most of the features of SAS/BASE while the rest of SAS/BASE can be accessed through Code Editor function. Besides the above features, Enterprise Guide also provides an OLE- automation server to run VBScript so that the user can automate some of the processes. Coupling with a task scheduling function in Enterprise Guide or Windows, users will be able to run a fairly complicated process automatically at a predetermined time and frequency. Enterprise Guide does not perform your analyses. It writes SAS code that gets passed-off to your SAS application. SAS then runs the code and passes the results back to Enterprise Guide. So, Enterprise Guide is not a stand-alone application. You must have SAS available to your machine. In fact, you must have SAS version 8 or a later version. The code that Enterprise Guide creates can be saved and run through SAS independently of Enterprise Guide. This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks in SAS that are not totally familiar. The TRANSPOSE procedure is an example that we often can't seem to write correctly the first time. It becomes a trial- and-error process until we get our desired results. Enterprise Guide has three tasks that use the Transpose procedure. Through those tasks, we can get our desired results the first time. The Tabulate procedure is very nicely done in Enterprise Guide in a way that allows us to easily and rather intuitively build a report table. We drag variables into the row headers and column headers and select the statistics. It is quite intuitive. Enterprise Guide has an fairly long list of tasks that it can develop in a point-and-click manner. These tasks use the following list of SAS procedures: ANOVA GCONTOUR PRINT AUTOREG GENMOD SQL CANCORR GLM RANK CAPABILITY GMAP REG CLUSTER GPLOT SHEWHART CORR GRADAR STANDARD DISCRIM LIFETEST SURVEYSELECT DISPLAY LOGISTIC TABULATE EXPAND MDDB TRANSPOSE FACTOR MEANS TREE FASTCLUS MIXED TSCSREG FORCAST NLIN TTEST FORMAT NPAR1WAY UNIVARIATE FREQ PARETEO G3D PHREG GCHART PRINCOMP So, Enterprise Guide is no lightweight. Now, it can't write the code to do everything that each of these procedures can do. But it can do most of the tasks and can get close on most of the rest. DEMONSTRATION BY EXAMPLE The authors will demonstrate the development of an Enterprise Guide application that is pertinent to the projects at Westat. THE TASK AT HAND Much of Westat's business involves survey processing. Samples are drawn from the appropriate universe, surveys are distributed, and the status of the surveys is maintained in applications that we call Receipt Control systems. These Receipt Control applications are often developed in Microsoft Access, although other software is occasionally used. A distinct Receipt Control database exists for each project. These Receipt Control applications usually have Graphics and Information Visualization NESUG 16 Graphics & Information Visualization NESUG 16

Upload: others

Post on 06-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

Enterprise Guide – A Code-Free Approach to Data Analysis and Reporting

Rachel Jiang and Ed Heaton, Westat, Rockville, MD

ABSTRACT Do you yearn for a code-free approach to data analysis

and reporting? Would you like a little help when you need to code procedures that you seldom use? If your answer is "Yes" to either of these questions then SAS® Enterprise Guide® may be the tool for you.

This paper will present SAS Enterprise Guide, a powerful Windows client application. Enterprise Guide is a useful, project-oriented tool that allows you to analyze your data quickly. With a straightforward interface, it helps you accomplish dozens of analytical and reporting tasks with little knowledge of SAS programming.

This application enables users with transparent access to both SAS and other types of data. Interactive task windows lead users through analyses and summaries, producing high quality SAS graphics. The results can be exported to other Windows applications and the Web. The ability to schedule a project to run later enables users to refresh and distribute reports automatically at regular intervals.

The authors will demonstrate some of the features of Enterprise Guide through a lifelike project.

WHAT IS ENTERPRISE GUIDE? SAS Enterprise Guide is an application that SAS

developed as a point-and-click software in order for non-SAS programmers to analyze data without mastering SAS programming skills. Meanwhile, it can also assist SAS programmers to develop SAS code by pointing and clicking inside the application. It has most of the features of SAS/BASE while the rest of SAS/BASE can be accessed through Code Editor function. Besides the above features, Enterprise Guide also provides an OLE-automation server to run VBScript so that the user can automate some of the processes. Coupling with a task scheduling function in Enterprise Guide or Windows, users will be able to run a fairly complicated process automatically at a predetermined time and frequency.

Enterprise Guide does not perform your analyses. It writes SAS code that gets passed-off to your SAS application. SAS then runs the code and passes the results back to Enterprise Guide. So, Enterprise Guide is not a stand-alone application. You must have SAS available to your machine. In fact, you must have SAS version 8 or a later version.

The code that Enterprise Guide creates can be saved and run through SAS independently of Enterprise Guide. This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks in SAS that are not totally familiar. The TRANSPOSE procedure is an example that we often can't

seem to write correctly the first time. It becomes a trial-and-error process until we get our desired results. Enterprise Guide has three tasks that use the Transpose procedure. Through those tasks, we can get our desired results the first time.

The Tabulate procedure is very nicely done in Enterprise Guide in a way that allows us to easily and rather intuitively build a report table. We drag variables into the row headers and column headers and select the statistics. It is quite intuitive.

Enterprise Guide has an fairly long list of tasks that it can develop in a point-and-click manner. These tasks use the following list of SAS procedures:

ANOVA GCONTOUR PRINT

AUTOREG GENMOD SQL

CANCORR GLM RANK

CAPABILITY GMAP REG

CLUSTER GPLOT SHEWHART

CORR GRADAR STANDARD

DISCRIM LIFETEST SURVEYSELECT

DISPLAY LOGISTIC TABULATE

EXPAND MDDB TRANSPOSE

FACTOR MEANS TREE

FASTCLUS MIXED TSCSREG

FORCAST NLIN TTEST

FORMAT NPAR1WAY UNIVARIATE

FREQ PARETEO

G3D PHREG

GCHART PRINCOMP

So, Enterprise Guide is no lightweight. Now, it can't write the code to do everything that each of these procedures can do. But it can do most of the tasks and can get close on most of the rest.

DEMONSTRATION BY EXAMPLE The authors will demonstrate the development of an

Enterprise Guide application that is pertinent to the projects at Westat.

THE TASK AT HAND

Much of Westat's business involves survey processing. Samples are drawn from the appropriate universe, surveys are distributed, and the status of the surveys is maintained in applications that we call Receipt Control systems. These Receipt Control applications are often developed in Microsoft Access, although other software is occasionally used. A distinct Receipt Control database exists for each project. These Receipt Control applications usually have

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 2: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

a reporting function to return the progress of the survey project at different stages of the process so that they can be reported at project meetings.

OUR MANAGER NEEDS MORE FREQUENT PROGRESS REPORTS.

We will use SAS Enterprise Guide to develop a reporting system that creates a bar graph of the status of each of the surveys under the domain of our manager. This bar graph will be recreated nightly and emailed to our manager in the early morning. The graph will use ActiveX to provide dynamic interactivity for the manager.

RECEIPT-CONTROL DATA IS KEPT IN MICROSOFT® ACCESS® DATABASES.

Each Receipt Control application that we will use is a MS Access application. This should not lead to a loss of generality because it is very easy to import data from many different sources into Enterprise Guide.

Each Receipt Control database has a table called RCON and each RCON table has a field called STATUS. This is a departmental standard but should lead to no loss of generality because it is easy to rename fields in Enterprise Guide.

Another departmental standard is the codes for the status of the survey. These are:

CM – completed by mail,

CF – completed by fax,

CP – completed by phone,

PM – returned by postmaster,

OS – out of scope for this survey,

RF – refused by recipient, and

Missing – survey still in the field. REPORT DAILY VIA EMAIL

Our solution will send an email to the manager every day with an HTML attachment. That HTML page will have a stacked bar graph, one bar for each survey, that reflects the percent of the sample that falls under each status code. The report should look something like the following, with possibly more bars to reflect all of the surveys that are active.

The graphs shown in Figure 1 are for surveys 101, 102, and 103. We organized the categories of the STATUS variable so that the completed surveys are on the bottom of the stack, the surveys that are definitely out of the picture are on the top of the graph, and the surveys that are up for grabs are reported in the middle of the graph.

Figure 1

So, the manager can look at the top of the completed

section to see the current response rate and can look at the top of the non-response section to see the potential for the final response rate. This is especially important because many contracts include a bonus if the final response rate is over a certain percent.

ENTERPRISE GUIDE SOLUTION When we boot-up Enterprise Guide, we get a screen

that asks us to select an existing project or to create a new project. Everything in Enterprise Guide is done within the bounds of a project. Let's create a new project called ProgressReport. Projects are stored in *.SEG files. ProgressReport now appears as the root of a tree in the Project window.

INSERT DATA

Now we need to insert our data tables into our project. It's a rather simple task; select Data from the Insert drop-down menu. We get an Insert Data window. There are two tabs: New and Existing. Select the Existing tab and you will see a familiar Windows file selection screen where we can select the file that has our data. Be sure to use the Files of type dialog to show the MS Access files. If our MS Access database contains multiple tables we will get a window that allows us to select the table we want to insert into our project. If there is only one table in the database it will be imported immediately. Multiple databases and multiple tables from those databases can be imported in one operation.

When we import our data, the data appear as tables in the main window. We can close these tables and they will still be available to us through the project tree. See figure 2 for a view of the project tree.

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 3: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

Figure 2

SUMMARIZE THE DATA

We want to run some one-way frequencies to produce the percent of the surveys that fall under each status code. Let's select the first of the tables we inserted so that Enterprise Guide knows what data we want to analyze. Since we are experienced SAS programmers, we know that we want to run the FREQ procedure. The task window has two tabs, one for Tasks by Category and one for Tasks by Name. Let's select the Tasks-by-Name category. We can click on the header for SAS Procedures and it will sort alphabetically. Now we can easily find the FREQ procedure. Double-clicking on the procedure name in the task window will open the following dialog window.

Figure 3

We will drag the STATUS variable into the Analysis

variables. Then, let's go to the Statistics tab (Figure 4) tell Enterprise Guide to show the frequencies for the missing values and to include them in the calculations.

Figure 4

Under the Results tab we need to select Save output as

Frequencies (Figure 5).

Figure 5

We need to repeat this process of summarizing the

Status variable for the other Receipt Control tables. When we are done, our project tree will look something like the following.

Figure 6

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 4: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

We see that the results of our FREQ procedure are displayed in HTML format. We also see that Enterprise Guide generated SAS code, a log, and a new table. This table has a very non-SAS name of Frequency of STATUS in Survey103(Rcon). In the SAS code that is generated, the names are made more SASy by substituting underscores for blanks, parentheses, etc.

COMBINE DATA FROM ALL OF THE SURVEYS

We need to combine the information from all of the surveys to produce our graph. However, the tables that were produced by the FREQ procedure have no variable that identifies the survey; we need to add such a variable. The addition of the new variable is accomplished through the Query window. With the output table from the FREQ procedure selected we can call the Query task.

Figure 7

Let's go to the Select and Sort tab (Figure 7). We don't

need the COUNT variable, only the STATUS and PERCENT variables. But we need a new variable to hold the name of the survey. Select the New button to add a variable.

Figure 8

The Alias (Figure 8) is really the name of the variable that we want to create. However, we need to give it a value. This happens under the Expression tab (Figure 9). All we need to do, in this case, is type the name of the survey, in quotes, in the dialog box.

Figure 9

Let's say "OK" to close this window and "Run Query"

to finish this task. We will need to perform similar tasks for the other Receipt Control tables. Our project tree will now look something like Figure 10. The output table from the query will have a name something like Results of Query1 for Frequency….

Figure 10

Now let's append the tables. We will select one of the

query result tables as a starting point. Then, from the Data drop-down menu, select Append Table… to get the following window.

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 5: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

Figure 11

Our starting table is displayed. Select the Add button

to add more tables. The tables we want to append are already in our project, so select the project tab below.

Figure 12

We will select the last two tables, Results of Query1 …

in Survey102(Rcon) and Results of Query1 … in Survey103(Rcon) (Figure 13).

Figure 13

Don't worry about the change in the names of the added

tables. Enterprise Guide does this, but the tables are the right ones. Under the Results tab, we will choose to create a view rather than a data set. Then we select the Finish button to run the code. The results are displayed in Figure 14.

Figure 14

CREATE VALUE-LABEL FORMAT

Now we need to create some value-label formats so that our manager won't have to guess at the meanings of the STATUS codes. Enterprise Guide has a task to help with this. Since we are SAS programmers, we know that we want to use the FORMAT procedure, so we will look under Tasks by Name. The FORMAT task brings up a window to create value-label formats. We need to give the format a name (STATUSF) and define it as a character

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 6: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

format. We will also set it's scope as temporary. Under the Define Format tab, EG provides explicit 5-step instructions on how to create a value-label format. (See figure 15.)

Figure 15

We need to apply these formats to our table. If we

apply these to the first table and append the other tables, the formats will apply to the final table. Let's open Query1 for Frequency of STATUS in Survey101(Rcon) and look at the properties of the STATUS variable. Under the Format tab (Figure 16), we can select the format from the User Defined category. We could also set the width if we desired; the default for our format is 20. That's all there is to it; oh yeah, we have to rerun the query.

Figure 16

We chose to make our formats temporary, so we need

to move their creation before their use. So, let's move the Create Format task above the Query1 for Frequency of STATUS in Survey101(Rcon) task. It's a simple drag and drop operation.

CREATE BAR CHART

Now we need to create our bar chart from the appended data. First we will select the Appended Data View. Then we will select Bar… from the Graph menu. We will get a window as in Figure 17.

Figure 17

We want a Stacked Vertical Bar. Under the Columns

tab, we need to drag SURVEY onto Column to chart, STATUS onto Stack bars by, and PERCENT onto Sum by.

Under the Appearance tab (Figure 18), we need to change the Number of bars to One bar for each unique data value. If we leave it at the default, we will get unpredictable results – for this exercise, we would get only one bar as shown!

Figure 18

That's all we need to produce our report. However, we

wanted to automate the process to run daily.

BUILD THE DOCUMENT

If we want to send the chart to our manager, we need to turn it into a web document. Select Document Builder… under the Tasks menu. In the Document Builder window that appears, we can name our document and then select Add Results… to select the HTML page that contains our bar chart. Figure 19 shows the window to add a result to the document.

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 7: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

Figure 19

Now the document will appear on in following the

Document Builder window.

Figure 20

CREATE THE PROCESS FLOW

We need to build a process flow so that all of the tasks can proceed as planned. Select Process Flow Builder… from the Tools menu to get the following window.

Figure 21

We already organized the tasks in the order that we

want them to run, so we simply need to select the Add Task button with Local highlighted in left window. A

view of the last part of the process flow diagram follows. The entire process flow diagram is fairly large.

Figure 22

It is probably a good idea to select the Run tasks now

box to make sure the process runs as planned.

CREATE EMAIL CODE

EG doesn't have an email builder, but it does allow us to write SAS code using an editor very much like the Enhanced Editor in Base SAS. To get the editor, select Code… from the Insert menu. We want to give our code a name so that it will be recognizable in our process flow. The SAS code for sending the email follows.

FileName mail email

"[email protected]"

subject="Survey Status Report"

attach="StatusReport.htm"

;

Data _null_ ;

File mail ;

today = today() ;

Put

"Libby:"

/ " The included attachment"

" shows the status of your "

/ " surveys as of "

today mmddyy10. "." /

/ "Rachel Jiang"

;

Run ;

Okay, our solution isn't entirely code free. In fact, we have some more code to write; but more about that later.

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 8: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

BUILDING THE EMAIL PROCESS FLOW

We need to build another process flow for the email task. This one is nice and simple (Figure 23); we simply add the single task.

Figure 23

SCHEDULING THE JOB

Okay, now we need some more code. This time it needs to be VB Script. Sorry!

You won't have to start from scratch. We got our starting point from Querying and Reporting Using Enterprise Guide Course Notes, by Jawna Gardner, Bill Powers, and Stacey Syphus. You can start from our code below.

'-----------------------------------------------

' Open the ProgressReport project, run the

' StatusReport process flow diagram (PFD), store

' the FinalReport document results to a file

' (StatusReport.htm). Then run the Process Email

' Task PFD to distribute the results through

' email.

'-----------------------------------------------

' Create the Enterprise Guide application.

Dim objGuide

Set objGuide = _

Wscript.createObject("SASEGuide.Application")

' Open the project called ProgressReport.

Dim ObjProject

Set ObjProject = _

objGuide.open("ProgressReport.seg")

' Access the PFD called StatusReport.

Dim objpfd

set objpfd = _

objproject.projectItems("StatusReport")

' Runthe PFD.

objpfd.run

' Get the document called FinalReport and save

' it as StatusReport.htm.

Dim objDoc

set objDoc = _

objproject.projectItems("FinalReport")

objDoc.saveas("StatusReport.htm")

' Access the PFD called Process Email Task.

Dim eml

set eml = _

objproject.projectItems("Process Email Task")

' Runthe PFD.

eml.run

' Close the project and shut down the

' application, notifying the user when done.

objProject.Close

objGuide.quit

MsgBox (" Enterprise Guide finished Running")

To put this code in EG, select ProgressReport from the project window and then select Schedule ProgressReport from the Tools menu.

Figure 24

Figure 25

The Visual Basic code resides in ProgressReport.vbs,

so we need to tell EG to run this file (Figure 24). Now we

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 9: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

need to set a time to run. Go to the Schedule tab (Figure 25).

You will probably have to set your account information.

Figure 26

That's it.

Depending on your site configuration, you might have to leave your PC running during this 6:00 AM slot when this job runs. You might also need to have your email client running.

CONCLUSION Enterprise Guide is a way for non-programmers to

develop analytical reports about their data. It allows programmers who are not familiar with SAS to quickly become productive. Even experienced SAS programmers will find it's code-writing features useful when they need to perform tasks that are more unfamiliar.

This process was developed in about four hours. We had very little experience with Enterprise Guide, but we had experimented with the built-in tutorial and we had the course notes mentioned above.

DISCLAIMER

The contents of this paper are the work of the authors and do not necessarily represent the opinions, recommendations, or practices of Westat.

REFERENCES

SAS® and all other SAS Institute Inc. product and service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Much information about Enterprise Guide can be found in Querying and Reporting Using Enterprise Guide Course Notes, by Jawna Gardner, Bill Powers, and Stacey Syphus (book code 59312). This book is available from SAS. Or, you could take the class of the same name (course code EGGS20).

ACKNOWLEDGEMENTS

We want to thank Michael Raithel of Westat for reviewing this paper and for his valuable suggestions.

CONTACT INFORMATION

Your comments and questions are valued and encouraged. Contact the authors at:

Rachel Jiang Edward Heaton Westat Westat 1650 Research Boulevard 1650 Research Boulevard Rockville, MD 20850 Rockville, MD 20850 Phone: (301) 294-2029 Phone: (301) 610-4818 Fax: (301) 294-3992 Fax: (301) 610-5128 [email protected] [email protected]

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16

Page 10: NESUG 16 Graphics and Information VisualizationGraphics ... · This is one of the beauties of Enterprise Guide for the experienced SAS programmer. We often are asked to perform tasks

Graphics and Information VisualizationNESUG 16 Graphics & Information VisualizationNESUG 16