Building a Marketing Dashboard using Excel and SAS. Tim Walters InfoTech Marketing



Similar documents
A Microsoft Access Based System, Using SAS as a Background Number Cruncher David Kiasi, Applications Alternatives, Upper Marlboro, MD

SPV Reporting Tool VBA Code User Guide. Last Updated: December, 2009

A Comparison of SAS versus Microsoft Excel and Access s Inbuilt VBA Functionality Jozef Tarrant, Amadeus Software Ltd., Oxford, UK

AN ANIMATED GUIDE: SENDING SAS FILE TO EXCEL

Create an Excel report using SAS : A comparison of the different techniques

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA

THE HELLO WORLD PROJECT

Programming in Access VBA

Writing Macros in Microsoft Excel 2003

Release 2.1 of SAS Add-In for Microsoft Office Bringing Microsoft PowerPoint into the Mix ABSTRACT INTRODUCTION Data Access

Abstract. Introduction. System Requirement. GUI Design. Paper AD

Managing very large EXCEL files using the XLS engine John H. Adams, Boehringer Ingelheim Pharmaceutical, Inc., Ridgefield, CT

A Method for Cleaning Clinical Trial Analysis Data Sets

ENHANCING SAS OUTPUT WITH OUTPUT DELIVERY SYSTEM (ODS)

Creating Dynamic Reports Using Data Exchange to Excel

Integrating SAS and Excel: an Overview and Comparison of Three Methods for Using SAS to Create and Access Data in Excel

Data Presentation. Paper Using SAS Macros to Create Automated Excel Reports Containing Tables, Charts and Graphs

1. a procedure that you perform frequently. 2. Create a command. 3. Create a new. 4. Create custom for Excel.

Excel & Visual Basic for Applications (VBA)

WEBFOCUS QUICK DATA FOR EXCEL

Developing an On-Demand Web Report Platform Using Stored Processes and SAS Web Application Server

CREATING FINANCIAL STATEMENTS

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

IENG2004 Industrial Database and Systems Design. Microsoft Access I. What is Microsoft Access? Architecture of Microsoft Access

SAS Add in to MS Office A Tutorial Angela Hall, Zencos Consulting, Cary, NC

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Training Needs Analysis

Microsoft Word 2013: Mail Merge

PharmaSUG Paper AD11

SAS ODS HTML + PROC Report = Fantastic Output Girish K. Narayandas, OptumInsight, Eden Prairie, MN

You have got SASMAIL!

Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX

Introduction. Syntax Statements. Colon : Line Continuation _ Conditions. If Then Else End If 1. block form syntax 2. One-Line syntax. Do...

Introduction to Macros and Visual Basic in Excel

Web Reporting by Combining the Best of HTML and SAS

Customized Excel Output Using the Excel Libname Harry Droogendyk, Stratia Consulting Inc., Lynden, ON

USC Marshall School of Business Marshall Information Services

Changing the Display Frequency During Scanning Within an ImageControls 3 Application

How To Create An Audit Trail In Sas

Applications Development

Big Data, Fast Processing Speeds Kevin McGowan SAS Solutions on Demand, Cary NC

Automation of Large SAS Processes with and Text Message Notification Seva Kumar, JPMorgan Chase, Seattle, WA

Methodologies for Converting Microsoft Excel Spreadsheets to SAS datasets

SENDING S IN SAS TO FACILITATE CLINICAL TRIAL. Frank Fan, Clinovo, Sunnyvale CA

A Concise Guide for Beginners LIEW VOON KIONG

SAS Macros as File Management Utility Programs

Health Services Research Utilizing Electronic Health Record Data: A Grad Student How-To Paper

Create Your Customized Case Report Form (CRF) Tracking System Tikiri Karunasundera, Medpace Inc., Cincinnati, Ohio

Using Microsoft Excel for Data Presentation Peter Godard and Cyndi Williamson, SRI International, Menlo Park, CA

Microsoft Excel 2013: Macro to apply Custom Margins, Titles, Gridlines, Autofit Width & Add Macro to Quick Access Toolbar & How to Delete a Macro.

Improve your Clinical Data Management With Online Query Management System

Macros allow you to integrate existing Excel reports with a new information system

Providing Password Protection to Excel Reports for Distribution in s

VBA Microsoft Access 2007 Macros to Import Formats and Labels to SAS

To create a histogram, you must organize the data in two columns on the worksheet. These columns must contain the following data:

Explore commands on the ribbon Each ribbon tab has groups, and each group has a set of related commands.

LabVIEW Report Generation Toolkit for Microsoft Office

Multi-DNC. by Spectrum CNC Technologies

Excel & Visual Basic for Applications (VBA)

Search and Replace in SAS Data Sets thru GUI

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

A Macro to Create Data Definition Documents

Microsoft Excel 2007 Mini Skills Overview of Tables

Using DDE and SAS/Macro for Automated Excel Report Consolidation and Generation

Excel Reporting with 1010data

Using GABRIEL Excel to XML Templates

Microsoft VBA Programming

ABSTRACT INTRODUCTION SAS AND EXCEL CAPABILITIES SAS AND EXCEL STRUCTURES

Microsoft Office 2000 and Security Against Macro Viruses

Reporting and Analysis Using Vivid Reports Flex

SHA 6050 Solver and VBA Lab

Using SAS Output Delivery System (ODS) Markup to Generate Custom PivotTable and PivotChart Reports Chevell Parker, SAS Institute

Using Loops to Repeat Code

LabVIEW Report Generation Toolkit for Microsoft Office User Guide

The Online Health Program Planner Part 1: Beginner's Guide

A Comparison of SAS versus Microsoft Excel and Access s Inbuilt VBA Functionality

Writing Data with Excel Libname Engine

Using Excel and VBA CHANDAN SENGUPTA SECOND EDITION. WILEY John Wiley & Sons, Inc.

Automated distribution of SAS results Jacques Pagé, Les Services Conseils HARDY, Quebec, Qc

Better Safe than Sorry: A SAS Macro to Selectively Back Up Files

RIT Installation Instructions

Importing Excel File using Microsoft Access in SAS Ajay Gupta, PPD Inc, Morrisville, NC

with VBA

Using SAS to Control and Automate a Multi SAS Program Process. Patrick Halpin November 2008

Advanced Excel Charts : Tables : Pivots : Macros

Pastel Evolution BIC. Getting Started Guide

Transcription:

Building a Marketing Dashboard using Excel and SAS Tim Walters InfoTech Marketing 1

Desired Outcome Dashboard Sheet and 6 Results Sheets 2

Client Environmental Considerations Client company has software to facilitate transfer of images between mobile phones and the Internet Environmental Factor Needed results in workbook for email distribution among key executives Needed flexibility in certain reporting parameters Adding capable handsets and sites over time Unknown technical skills of people running system Expected large influx of customers May not have SAS PC Files module Resulting Decision Workbook must include all data. No external references allowed User selects parameters Stop system when new information encountered Make interface simple and from familiar source (Excel) Use SAS for processing Write output files using ODS 3

System Overview User Opens Excel Workbook User Completes Workbook Form User Runs Launches SAS & Excel Monitors User Distributes Results Workbook Populated SAS Processing 4

1. User Opens Excel Workbook Folder Location of SAS 5

2. User Completes Workbook Form 6

3. User Runs Launches SAS Private Sub Run_Click() access_type = &H400 still_active = &H103 'this will be used to delete files and check for existence Set fsofile = CreateObject("scripting.filesystemobject") a = ThisWorkbook.path On Error Resume Next fsofile.deletefile (a & "\phone_errors.xls") 'Deletes existing file fsofile.deletefile (a & "\site_errors.xls") 'Deletes existing file sas_location = Workbooks("company Reports.xls").Worksheets("Sheet1").Range("B1").Value sas_program = a & "\ReadWeeklyFiles.sas" datec = "'" & Application.WorksheetFunction.Text(Calendar1, "ddmmmyy") & "'" & "d" runparm = a & "\$" & datec & "$" & WeeklyFile & "$" & Weeks & "$" & CountryCutoff & "$" & HeavyUsers & _ "$" & PreviouslyActive & "$" & AccountsUsingBackup & "$" & UploadActivity & "$" & SitesConfigured _ & "$" & UploadSites & "$" & NumDaysUploads & "$" & NumDaysActiveUploads & "$" & _ OTA_Downloads completeline = sas_location & " -sysin " & sas_program & " -log " & a & " -noprint -sysparm " & runparm 'uses shell execute taskid = Shell(completeline, 1) hproc = OpenProcess(access_type, False, taskid) 7

3. User Runs Excel Monitors Do 'loop continuously 'check on the process GetExitCodeProcess hproc, lexitcode 'allow event processing DoEvents Loop While lexitcode = still_active currpath = ActiveWorkbook.path If fsofile.fileexists(currpath & "\phone_errors.xls") Then MsgBox ("New phones exists. Please update handsets.csv and re-submit") Workbooks.Open (currpath & "\phone_errors.xls") Workbooks.Open (currpath & "\handsets.csv") stopper = "Yes" End If If fsofile.fileexists(currpath & "\site_errors.xls") Then MsgBox ("New sites exists. Please update parameters.csv and re-submit") Workbooks.Open (currpath & "\site_errors.xls") Workbooks.Open (currpath & "\parameters.csv") stopper = "Yes" End If If stopper <> "Yes" Then Workbooks.Open (currpath & "\Weekly Dashboard.xls") Me.Hide Unload Me End Sub 8

4. SAS Processing ReadWeeklyFiles.sas Read 14 Parameters Passed %macro createmacvars; %global week_date folder filedate ; %let folder=%scan(%quote(&sysparm),1,$); %let week_date=%scan(%quote(&sysparm),2,$); %let filedate=%scan(%quote(&sysparm),3,$); %let weeks=%scan(%quote(&sysparm),4,$); %let country_cutoff=%scan(%quote(&sysparm),5,$); %let heavy_users=%scan(%quote(&sysparm),6,$); %let previous_active=%scan(%quote(&sysparm),7,$); %let accounts_using_backup=%scan(%quote(&sysparm),8,$); %let upload_activity=%scan(%quote(&sysparm),9,$); %let sites_configured=%scan(%quote(&sysparm),10,$); %let upload_sites=%scan(%quote(&sysparm),11,$); %let num_days_uploads=%scan(%quote(&sysparm),12,$); %let num_days_active_uploads=%scan(%quote(&sysparm),13,$); %let ota_downloads=%scan(%quote(&sysparm),14,$); %mend; %createmacvars; 9

4. SAS Processing ReadWeeklyFiles.sas Program Aspects All files must be in the same folder. Folder name used for input/output files Input %let userfile=&folder&filedate Users & Accounts.csv; %let parafile=&folder.parameters.csv; %let handfile=&folder.handsets.csv; Output %let out_errors=&&folder.phone_errors.xls; %let out_weekly=&&folder.weekly.xls; 10

4. SAS Processing ReadWeeklyFiles.sas Stop Program for New Data %macro stopp; %if &obs_errors > 0 %then %do; ods html file="&&out_errors" style = printer headtext="<style> TD {MSO-NUMBER- FORMAT:\#\#\,\#\#\#\,\#\#0;}</STYLE>"; title; proc print data=phone_errors(keep=phone_text_1_20) &printstyle; run; ods html close; %abort; %end; %if &site_o_errors > 0 %then %do; ods html file="&&out_site_errors" style = printer headtext="<style> TD {MSO-NUMBER- FORMAT:\#\#\,\#\#\#\,\#\#0;}</STYLE>"; title; proc print data=site_errors(keep=site_code) &printstyle; run; ods html close; %abort; %end; %mend; /* this macros gets the number of observations and number of columns for certain datasets */ %macro obsnvars(ds); %global dset vars_phones vars_sites obs_errors sites_obs site_o_errors; %let dset=&ds; %let dsid = %sysfunc(open(&dset)); %if &dsid %then %do; %if &ds=phone_errors %then %let obs_errors=%sysfunc(attrn(&dsid,n obs)); %if &ds=site_errors %then %let site_o_errors=%sysfunc(attrn(&dsi d,nobs)); %let rc = %sysfunc(close(&dsid)); %end; %else %put Open for data set &dset failed - %sysfunc(sysmsg()); %mend obsnvars; /* data file of new types not in table */ data phone_errors; set company.userphone; if phone_type=" "; run; %obsnvars(phone_errors); data site_errors; set company.usersite; if site_type=" "; run; %obsnvars(site_errors); /* invoke stopp macro -- if phone or site errors, stops awaiting user correction */ %stopp; 11

4. SAS Processing ReadWeeklyFiles.sas Output Files Using ODS Main File ods html file="&&out_weekly" style = printer headtext="<style> TD title; {MSO-NUMBER- FORMAT:\#\#\,\#\#\#\,\#\#0;}</ STYLE>"; proc print data=weekly_report_out(wher e=(week_activated ne -10)) &printstyle; run; var _numeric_ ; ods html close; Parameters File Fed Back to Excel data uploads_28_final; run; weeks=symget('weeks'); heavy_users=symget('heavy_users'); previous_active=symget('previous_active'); country_cutoff=symget('country_cutoff'); ods html file="&&out_within_28" style = printer headtext="<style> TD title; {MSO-NUMBER- FORMAT:\#\#\,\#\#\#\,\#\#0;}</STYLE>"; proc print data=uploads_28_final &printstyle; run; ods html close; 12

5. Results Workbook Populated Weekly Dashboard.xls VBA Code in Microsoft Excel Objects This Workbook 13

5. Results Workbook Populated Weekly Dashboard.xls Sub Chart_Update() Application.ScreenUpdating = False Application.DisplayAlerts = False Application.EnableEvents = False a = ThisWorkbook.Path pp = "Weekly Dashboard.xls" With Workbooks(pp) ' Clear existing worksheets.worksheets("within28").cells.clearcontents.worksheets("weekly").cells.clearcontents.worksheets("countries active").cells.clearcontents End With ' start by processing within 28 file Workbooks.Open (a & "\within28.xls") Workbooks("within28.xls").Worksheets("within28").Cells.Select selects all cells from workbook Selection.Copy copy Workbooks(pp).Worksheets("within28").Activate activate worksheet you want Range("A1").Select ActiveSheet.Paste 14

5. Results Workbook Populated Weekly Dashboard.xls More Chart_Update Macro Statements Application.ScreenUpdating = True Application.DisplayAlerts = True Application.EnableEvents = True End Sub 15

6. User Distributes Checks Data, Manually Saves, and Manually Emails 16

Advantages/Disadvantages of Excel-SAS-Excel System Advantages Use Excel charts/formatting Utilize powerful SAS processing User can run from familiar interface Ubiquity of Excel Limit SAS licensing Disadvantages Must know some VBA and its peculiarities May hit Excel row/column limits 64,000 in Excel 2003, 1 million in Excel 2007 17

For More Information Tim Walters InfoTech Marketing 720-732-4588 tim@infotechmarketing.net 18