A Dynamic Imagemap Generator Carol Martell, Highway Safety Research Center, Chapel Hill, NC

Similar documents
Using SAS/GRAPH Software to Create Graphs on the Web Himesh Patel, SAS Institute Inc., Cary, NC Revised by David Caira, SAS Institute Inc.

The GANNO Procedure. Overview CHAPTER 12

Creating Regional Maps with Drill-Down Capabilities Deb Cassidy Cardinal Distribution, Dublin, OH

ET01. LIBNAME libref <engine-name> <physical-file-name> <libname-options>; <SAS Code> LIBNAME libref CLEAR;

The GREMOVE Procedure

ABC s of Graphs in Version 8 Caroline Bahler, Meridian Software, Inc.

Fly over, drill down, and explore

A Guided Tour Through the SAS Windowing Environment Casey Cantrell, Clarion Consulting, Los Angeles, CA

Web-Application Bar Charts without SAS/GRAPH. Steve James, Centers for Disease Control and Prevention, Atlanta, GA

Using Graph-N-Go With ODS to Easily Present Your Data and Web-Enable Your Graphs Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

ABSTRACT MORE THAN SYNTAX ORGANIZE YOUR WORK THE SAS ENTERPRISE GUIDE PROJECT. Paper 50-30

HTML for the SAS Programmer

The Basics of Map Creation with SAS/GRAPH. Mike Zdeb School of Public Health Rensselaer, NY

Making Presentations More Fun with DATA Step Graphics Interface (DSGI) Hui-Ping Chen, Eli Lilly and Company, Indianapolis, Indiana

Information Visualization

Put Your Data on the Map: Using the GEOCODE and GMAP Procedures to Create Bubble Maps in SAS

Using Adobe Contribute 4 A guide for new website authors

The GTESTIT Procedure

SAS Graphs in Small Multiples Andrea Wainwright-Zimmerman, Capital One, Richmond, VA

Information Visualization

Adventures in Building Web Applications: A Tutorial on Techniques for Real-World Applications

HTML Exercise 21 Making Simple Rectangular Buttons

ODS Meets SAS/IntrNet

Geocoding Crashes in Limbo Carol Martell and Daniel Levitt Highway Safety Research Center, Chapel Hill, NC

Paper Mapping Roanoke Island Revisited: An OpenStreetMap (OSM) Solution. Barbara Okerson, Anthem Inc.

A Generalized Macro-Based Data Reporting System to Produce Both HTML and Text Files

A Picture Is Worth A Thousand Data Points - Increase Understanding by Mapping Data. Paul Ciarlariello, Sinclair Community College, Dayton, OH

Paper Abstract. Introduction. SAS Version 7/8 Web Tools. Using ODS to Create HTML Formatted Output. Background

Using SAS/GRAPH Software to Create Graphs on The Web Himesh Patel, SAS Institute Inc., Cary, NC

ColdFusion and SAS : No Pain Meds Required Carol Martell, UNC Highway Safety Research Center, Chapel Hill, NC

Authoring World Wide Web Pages with Dreamweaver

SAS Solutions for the Web: Static and Dynamic Alternatives Matthew Grover, S-Street Consulting, Inc.

Leveraging SAS Visualization Technologies to Increase the Global Competency of the U.S. Workforce

USING PROC GMAP AND DRILL-DOWN GRAPHICS FOR DATA QUALITY ASSURANCE Meghan Arbogast, Computer Sciences Corporation, Corvallis, OR

What s New in SAS Studio?

Multiple Graphical and Tabular Reports on One Page, Multiple Ways to Do It Niraj J Pandya, CT, USA

The Evolution of a SAS/GRAPH Application Jenine Eason, AutoTrader.com, Atlanta, GA

Enterprise Client Software for the Windows Platform

SAS/GRAPH Introduction. Winfried Jakob, SAS Administrator Canadian Institute for Health Information

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

Guide to Editing Map Legends

EXPORTING SAS OUTPUT ONTO THE WORLD WIDE WEB

FrontPage 2000 Tutorial -- Advanced

Taking advantage of the SAS System on OS/390

Version 8 ODS (Output Delivery System)

Submitting Code in the Background Using SAS Studio

QUERIES BY ODS BEGINNERS. Varsha C. Shah, Dept. of Biostatistics, UNC-CH, Chapel Hill, NC

Easing into Data Exploration, Reporting, and Analytics Using SAS Enterprise Guide

An Introduction to PROC GREPLAY

Paper ###-YYYY. SAS Enterprise Guide: A Revolutionary Tool! Jennifer First, Systems Seminar Consultants, Madison, WI

Internet, Intranets, and The Web

Internet/Intranet, the Web & SAS

WPS Workbench. user guide. "To help guide you through using the WPS user interface (Workbench) to create, edit and run programs"

ODS and Web Enabled Device Drivers: Displaying and Controlling Large Numbers of Graphs. Arthur L. Carpenter and Richard O. Smith Data Explorations

Using MACRO and SAS/GRAPH to Efficiently Assess Distributions. Paul Walker, Capital One

1.0 Overview For content management, Joomla divides into some basic components: the Article

A Revolution? Development of Dynamic And Hypertext Linked Reports With Internet Technologies and SAS System

Case Studies in Data Management on the Web. Carol Martell, UNC Highway Safety Research Center, Chapel Hill, NC

SAS/IntrNet 9.2. Overview. SAS Documentation

Using Big Data to Visualize People Movement Using SAS Basics

Intermediate Microsoft Word 2010

Coders' Corner. Paper Scrolling & Downloading Web Results. Ming C. Lee, Trilogy Consulting, Denver, CO. Abstract.

Routing Output. Producing Output with SAS Software CHAPTER 6

Creating Dynamic Web-based Reporting Dana Rafiee, Destiny Corporation, Wethersfield, CT

ODS/RTF Pagination Revisit

SAS/IntrNet 9.3. Overview. SAS Documentation

AOS Lab 4 HTML, CSS and Your Webpage

The GIMPORT Procedure

Chapter 27 Saving and Printing Graphics

Extending the Scope of Custom Transformations

Compatibility with graphing calculators 32 Deleting files 34 Backing up device files 35 Working with device screens 36 Capturing device screens 36

Getting Started with Processing by Casey Reas and Ben Fry

Improving Your Relationship with SAS Enterprise Guide Jennifer Bjurstrom, SAS Institute Inc.

What You Will Learn Today

Introduction. CHAPTER 3 Working in the SAS Windowing Environment

File Cabinet Manager

NEW FEATURES IN FOUNDATION SAS 9.4 CYNTHIA JOHNSON CUSTOMER LOYALTY

Controlling Titles. Purpose: This chapter demonstrates how to control various characteristics of the titles in your graphs.

Goldfish 4. Quick Start Tutorial

While editing a page, a menu bar will appear at the top with the following options:

SOFTWARE AND HARDWARE REQUIREMENTS In order to use Design-time Controls, you must meet the following software and hardware requirements.

USER GUIDE. MADCAP FLARE 2017 r3. QR Codes

Insert/Edit Image. Overview

SliceAndDice Online Manual

I KNOW HOW TO PROGRAM IN SAS HOW DO I NAVIGATE SAS ENTERPRISE GUIDE?

Utilizing SAS for Cross- Report Verification in a Clinical Trials Setting

SAS/ASSIST Software Setup

Effective Forecast Visualization With SAS/GRAPH Samuel T. Croker, Lexington, SC

Creating Web Pages with SeaMonkey Composer

A Practical Introduction to SAS Data Integration Studio

ABSTRACT: INTRODUCTION: WEB CRAWLER OVERVIEW: METHOD 1: WEB CRAWLER IN SAS DATA STEP CODE. Paper CC-17

Joomla! 2.5.x Training Manual

Paper AD12 Using the ODS EXCEL Destination with SAS University Edition to Send Graphs to Excel

About Netscape Composer

Knit Perl and SAS Software for DIY Web Applications

Making Backgrounds With Paint Shop Pro

CROMWELLSTUDIOS. Content Management System Instruction Manual V1. Content Management System. V1

Recitation 3 Further Work with Dreamweaver and Photoshop: Refining your Web Site

Creating Population Tree Charts (Using SAS/GRAPH Software) Robert E. Allison, Jr. and Dr. Moon W. Suh College of Textiles, N. C.

Basic Intro to ETO Results

Transcription:

A Dynamic Imagemap Generator Carol Martell, Highway Safety Research Center, Chapel Hill, NC ABSTRACT We learned that our web developers were turning a picture of the state of North Carolina with its one hundred counties into an imagemap by manually outlining each county. Ouch! SAS/GRAPH does a lovely job via SAS/INTRNET. The web developers kept changing their minds about the size of the image, so I wrote a little SAS job that uses Application Dispatcher to return the imagemap to the browser. The user supplies various parameters in a form and in return gets a link to the generated imagemap. The user can then save as and save image as to get both pieces for placement elsewhere. The application is generalized to generate a map of any state. INTRODUCTION An imagemap, once obtained, cannot be correctly resized using today s GUI-based html editors. One can resize the gif image, but the map coordinates do not change accordingly. This application makes imagemap recreation a breeze. Beginning with interactively generating a simple map of North Carolina, this paper steps through the process of moving from the interactive environment to the web. At each new step, additional code is shown in bold typeface. Since the intention is that the out generated be incorporated into other html, the map is purposefully devoid of legend, title, footnotes, etc. This paper assumes familiarity with running Application Dispatcher. select distinct county, 1 as mapv from two Reset the graphics options and then specify the gif device driver. We ve chosen a white background for an image. Pattern statements assign colors for map variable levels. Since there is only one value for mapv, we need only one pattern. goptions reset goptions device=gif cback=white pattern1 color=blue GENERATING A MAP INTERACTIVELY We can produce the map in an interactive session as follows. data=dummy Figure 1 shows the resulting map. PREPARATION The first step is to prepare in data for PROC GMAP: a map dataset and the data to be mapped. SAS provides various map datasets, one of which is Counties, an unprojected map dataset. The state and county variables in the table are fips codes. SAS has several functions for manipulating fips state codes. We create a new map dataset by subsetting for North Carolina records: data two set maps.counties if state=stfips("nc") Since Counties is unprojected, we run PROC GPROJECT to ensure the map will be undistorted. proc gproject data=two out=one The SAS table containing data to be mapped must contain the id variable to link with the map dataset. In this case id is county. GMAP also requires a variable to be mapped onto the state. We call it mapv and assign the value 1 for each county, so every county in the dataset will map as equal. To be mapped, each county must have an observation. The easiest way to get all the county codes is to pull them from the map dataset, because fips county code assignments are not intuitive. proc sql create table dummy as Figure 1 GENERATING A MAP INTERACTIVELY USING ODS The following additions use the Out Delivery System to create an html file treating the map as a simple gif, not an imagemap. The ODS path parameter gives the hard path for writing both the html and the gif file. Specifying the path in a filename statement rather than directly in the ods statement prevents incorporation of the path into the html gif reference. Without the path, the browser will simply look in the current directory for the gif file. filename o directory/path/for/files body= pagename.html data=dummy

Browsing to pagename.html, we again see the map of North Carolina. Viewing the html source code reveals the reference <IMG SRC="mymap.gif" border="0">. GENERATING A MAP FROM THE WEB Leaving the interactive session behind, we place our SAS code in a program library defined to the Application Dispatcher. We then generate the map using either a URL or a web form. With Application Dispatcher, one usually supplies an ODS html body parameter of _webout (dynamic) to send the out to the browser window. In this instance, however, there must still exist a gif file for the page to reference. When we change the body parameter to _webout, we find that the reference to the gif file (in the current directory) no longer works. Moving the path out of the filename statement and into the ODS html statement will not work because SAS is writing to a hard path while the html reference to the gif is URL-based. The solution is to use a base parameter. The base parameter provides the URL prefix to correctly locate the gif file from an html page. Whenever running graphics using Application Dispatcher, it is important to first close the ODS listing destination. Otherwise, SAS will attempt to write a copy of the image where the broker application resides. ods listing close filename o directory/path/for/files body=_webout (dynamic) base= complete-url-to-directory-o/ data=dummy There is another complication involving browser caching with the above code. Even with browser preferences set to always obtain files from the server rather than use a cached version, the gif may still be pulled from cache. Manually refreshing the _webout page simply reruns the program, which again uses the cached gif. One can open image in new window and then successfully refresh, but this is not particularly acceptable. One workaround is to write the html to a file rather than to _webout. A simple data step can, using statements, compose an intermediate page with a link to the html file containing the map. The user can click that link to bring the map page into the browser. Since the page showing the gif is no longer _webout, it can be refreshed without resubmitting the job. The base parameter is not needed in this workaround. Instead, we revert to using a path defined in a filename statement, causing the browser to look for the gif in the current directory. ods listing close filename o directory/path/for/files body= myfile.html data=dummy data _null_ file _webout Content-type: text/html Click below to see your map <a href= url-to-myfile.html >map</a> SPECIFYING THAT THE MAP BE AN IMAGEMAP For the examples thus far, the original in data was sufficient. For an imagemap, however, SAS requires a third variable in the data to be mapped, the link variable. This variable should hold the html link value to use with the current observation. This is the variable that allows different counties to link to different web pages. To keep our example simple, we assume there exists an html page for each county named fipscode.html. In other words, for a fips county code of 25, to get a link pointing to 25.html the variable value should be a href= 25.html. The imagemap parameter on the PROC GMAP statement causes all the polygon coordinates for each county to be html-encoded. The html parameter on the CHORO statement indicates the link variable. proc sql create table dummy as select distinct county, 1 as mapv, a href=" trim(left((i,3.))).html" as linkvar from two ods listing close filename o directory/path/for/files body= myfile.html data=dummy imagemap=m name= mymap html=linkvar data _null_ file _webout Content-type: text/html Click below to see your map <a href= url-to-myfile.html >map</a> Browsing to myfile.html reveals a map looking exactly like those already created. This time, however, when the mouse is passed over the state, links are visible and each county links to a different page.

LETTING THE USER CUSTOMIZE THE MAP The application incorporates the following as variables: NAME St Yp Xp hsqname progname mapcolor Co Transp cb Table 1 DESCRIPTION State Ypixels goptions size parameter. Determines height of image. Xpixels goptions size parameter. Determines width of image A base for an htmsql reference. If, for example, mybase is entered, the link for county 25 will be mybase.hsql?co=25 A program name for an Application Dispatcher link. If a.b.sas were entered: url?_program=a.b.sas&_service=default&co=25 Color used for all counties. Any valid SAS color name may be used. For example, in addition to named colors, HTML hex specs like #FFCC00 are used in SAS with a CX prefix, as in CXFFCC00. County outline color Specifies a transparent background Image background color The fields listed in table 1 are used in the web form shown in figure 2. When using Application Dispatcher, form field values are passed to the SAS program as macro variables. Placing the program code inside a macro enables the use of macro programming language. The following code makes use of all the options listed in the form. %global st transp xp yp cb co hsqname progname mapcolor %macro amap data two set maps.counties if state=stfips("&st") proc gproject data=two out=one proc sql create table dummy as select distinct county, 1 as mapv, a href=" %if &hsqname ne %then "%trim(&hsqname)".hsql?co= left((county,3.)) " %else %if &progname ne %then "%trim(&_url)"?service=_default&_program= "%trim(&progname)" &co= left((county,3.)) " %else trim(left((county,3.))).html" as linkvar from two goptions reset ods listing close filename o /mypath body= amap.html goptions device=gif %if "&transp"="yes" %then transparency %if &cb ne %then cback=&cb %if &xp ne %then xpixels=&xp %if &yp ne %then ypixels=&yp %if &pattern1 ne %then pattern1 color=&mapcolor data=dummy imagemap=m choro mapv/ coutline= %if &co eq %then black %else &co html=linkvar name= forweb nolegend Figure 2 data _null_

file _webout Content-type: text/html <title>imagemap Results</title> <font size=+3 align=center> Click the link below to see your map. </font><p> '<font size=+2 align=center> You must perform <font color=red>two</font>' saves to the same directory.</font><p>' '<table><font align=center> <tr><td>' "save as" for the html <td> <font size=+2 color=orange>and</font> <td> "save image as" for the gif file. </tr><tr></tr> '<tr><td> <font size=+2 color=green>ok</font> to rename html<td> <font size=+2 color=orange>but</font><td> <font size=+2 color=red>do not</font> rename the gif file '</tr><tr><td>' <a href="myurlpath/amap.html"> <font size=+3>map</font></a> '</font></table>' '<font size=+3 color=orange>note:</font> Make sure your browser refreshes both html and image for repetitive map generations. %mend amap %amap A CUSTOMIZED EXAMPLE The user requests a map of North Carolina 200 pixels tall by 300 pixels wide. Links are to be htmsql links. The htmsql page is hpage.hsql. The map should be gray with counties outlined in white on a black background. Figure 3 shows this request. Figure 3 Figure 4 Figure 4 shows the message returned to the browser. The user clicks on the word map to reveal figure 5.

Figure 5 The mouse is positioned over the state, and the URL appears in figure 6. Figure 6 SUMMARY This application uses the Version 8.0 SAS Out Delivery System and SAS/GRAPH with Version 2.0 Application Dispatcher to process graph customizations from a web form. The resulting graph is an imagemap of any state in the US with the associated links taking one of three forms: Application Dispatcher calls, htmsql calls, or html page references. Size and colors are to the user s specifications. Using an intermediate page for out that links to the requested imagemap circumvents problems related to browser caching. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Carol Martell UNC Highway Safety Research Center 730 Airport Rd, CB# 3430 Chapel Hill, NC 27599-3430 Work Phone: 919-962-8713 Fax: 919-962-8710 Email: carol_martell@unc.edu SAS, SAS/GRAPH and SAS/INTRNET are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration.