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

Similar documents
ABSTRACT INTRODUCTION TRICK 1: CHOOSE THE BEST METHOD TO CREATE MACRO VARIABLES

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

HyperText Markup Language/Tables

HTML for the SAS Programmer

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

Page Layout Using Tables

1. Please, please, please look at the style sheets job aid that I sent to you some time ago in conjunction with this document.

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

Dreamweaver CS3 Concepts and Techniques

Tutorial 5 Working with Tables and Columns. HTML and CSS 6 TH EDITION

FCKEditor v1.0 Basic Formatting Create Links Insert Tables

Chapter 4 Notes. Creating Tables in a Website

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

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

Tables *Note: Nothing in Volcano!*

Dynamism and Detection

COMSC-030 Web Site Development- Part 1. Part-Time Instructor: Joenil Mistal

Creating Accessible Web Sites with EPiServer

Microsoft Expression Web Quickstart Guide

Square Peg, Square Hole Getting Tables to Fit on Slides in the ODS Destination for PowerPoint

By Ryan Stevenson. Guidebook #2 HTML

Sign in and join ADC Newsletters Feedback. Creating your first website Part 2: Creating the page layout

Let There Be Highlights: Data-driven Cell and Row Highlights in %TAB2HTM and %DS2HTM Output

One SAS To Rule Them All

Web Design 101. What is HTML? HTML Tags. Web Browsers. <!DOCTYPE html> <html> <body> <h1>my First Heading</h1> <p>my first paragraph.

Html basics Course Outline

Creating Universally Designed Word 2010 Documents - Quick Start Guide

ODS/RTF Pagination Revisit

ADOBE DREAMWEAVER CS4 BASICS

Rich Text Editor Quick Reference

CSC 101: PreLab Reading for Lab #4 More HTML (some of this reading on Tables and Images are based on previous writings of Prof William Turkett)

HTML Images - The <img> Tag and the Src Attribute

HTML & XHTML Tag Quick Reference

Excel 2013 for Beginners

Creating Universally Designed Word 2013 Documents - Quick Start Guide

Understanding How FrontPage Works

USER GUIDE. MADCAP FLARE 2017 r3. QR Codes

Welcome to Introduction to Microsoft Excel 2010

Version 8 ODS (Output Delivery System)

Styles, Style Sheets, the Box Model and Liquid Layout

9.2 Types of Errors in Hypothesis testing

Using Dreamweaver CS6

Bootstrap All-in-One

Something for Nothing! Converting Plots from SAS/GRAPH to ODS Graphics

Adobe Dreamweaver CC 17 Tutorial

Variables Defined. THEME.DAT file. Storefront Variables. Sample HTML Source. THEME.DAT line descriptions Sample variable listing

District And Club Database

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

ODS for PRINT, REPORT and TABULATE

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

Developing Graphical Standards: A Collaborative, Cross-Functional Approach Mayur Uttarwar, Seattle Genetics, Inc., Bothell, WA

Using Proc Freq for Manageable Data Summarization

EXPORTING SAS OUTPUT ONTO THE WORLD WIDE WEB

Project Management System

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

A Novel Approach to Patient Profiling

Chapter 4 Creating Tables in a Web Site Using an External Style Sheet

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

Adobe Dreamweaver CS5 Tutorial

HTML2PDF. User manual

Centricity 2.0 Section Editor Help Card

Dreamweaver MX Overview. Maintaining a Web Site

2004 WebGUI Users Conference

Unit 5 Web Publishing Systems Page 1 of 13 Part 4 HTML Part 4

HTML Exercise 24 Tables

Attributes & Images 1 Create a new webpage

Internet, Intranets, and The Web

Information Visualization

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 8. Worksheets for Intervention Classes

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 7. Worksheets for Intervention Classes

Introduction to Computer Science (I1100) Internet. Chapter 7

INFS 2150 / 7150 Intro to Web Development / HTML Programming

Using Adobe Contribute 4 A guide for new website authors

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

CS 1124 Media computation. Lab 9.3 October 24, 2008 Steve Harrison

BusinessObjects Frequently Asked Questions

Paper SAS USER DOCUMENTATION: WEB PAGE DESIGN MADE EASY. Bruce Gilsen, Federal Reserve Board Scott Hoenig, Federal Reserve Board

HTML = hyper text markup language

CSC 121 Computers and Scientific Thinking

Web Site Design and Development Lecture 13

Using Dreamweaver. 4 Creating a Template. Logo. Page Heading. Home About Us Gallery Ordering Contact Us Links. Page content in this area

PERSONAL COMPUTING WEEBLY CLASS PROJECT

Paper Phil Mason, Wood Street Consultants

***OPEN IMODULES IN CHROME*** 1) Choose Home:

EVALUATION COPY. Unauthorized Reproduction or Distribution Prohibited

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay.

AOS Lab 4 HTML, CSS and Your Webpage

HTML. LBSC 690: Jordan Boyd-Graber. October 1, LBSC 690: Jordan Boyd-Graber () HTML October 1, / 29

Graduating to Grid. An Event Apart Orlando

Title: Jan 29 11:03 AM (1 of 23) Note that I have now added color and some alignment to the middle and to the right on this example.

Create and edit word processing. Pages.

The GANNO Procedure. Overview CHAPTER 12

Blog Pro for Magento 2 User Guide

Quick Results with the Output Delivery System

ODS Meets SAS/IntrNet

Getting Started with Image Fields

HTML Exercise 20 Linking Pictures To Other Documents Or Web Sites

Web Enabled Graphics with a SAS Data Warehouse Diane E. Brown, TEC Associates, Indianapolis, IN

Working with Tables in Word 2010

Transcription:

Web-Application Bar Charts without SAS/GRAPH Steve James, Centers for Disease Control and Prevention, Atlanta, GA ABSTRACT A picture is worth 1000 words it s said. And while that may be true, producing a picture instead of words can sometimes be 1000 times more difficult. That s particularly true if you re not familiar with SAS/Graph and Annotate. The Internet is a great medium for displaying graphics, but producing them can be troublesome. Anything that would make the task more simple would be welcomed. With creative uses of HTML tables and images, you can create a bar chart to display information without using SAS/Graph or Annotate. This paper describes how. Note: This paper assumes the reader has a working knowledge of HTML and SAS/IntrNet. INTRODUCTION In developing a web application displaying Injury Mortality Statistics for the Centers for Disease Control and Prevention, I came across a problem in that I wanted to display the breakdown of certain Injury categories in a meaningful and understandable way. A tabular format (see Figure 1) would provide the necessary format, but lacked the impact of a graphical display. 1997 US Homicide Deaths, Ages 25-34 Cause of Number of Death Deaths Percentage Firearm 3,764 74.8% Cut/Piercing 575 11.3% etc. Figure 1 - Tabular Format USING SAS/GRAPH AND ANNOTATE A SUGI 24 paper from LeRoy Besseler entitled Show Them What s Important: Solutions for a Finite Workday in an Era of Information Overload contained a graph in the format I wanted and contained the code to create such a graph using SAS/Graph and Annotate. A graph for my use would look something like figure 2. This graph has a much better visual impact than the simple tabular chart. Unfortunately it wasn t easy to produce because some of the labels were too long to display properly without a lot of extra work. Was there another way? HTML SOLUTION I knew I could construct a table using standard HTML commands to hold the textual information, but the big questions was how would I get the horizontal bars to generate. It turned out that using the WIDTH= and HEIGHT= parameters of the HTML image tag would give me what I needed. All I needed was to produce a one-pixel.gif file for the color I wanted, and then specify the width and height that I wanted it displayed. I could generate the HTML dynamically and thus vary the chart based on the input criteria I needed. In it s simplest form, the HTML code would look like this: <IMG border=0 height=h src="red.gif" width=w> where h and w were parameters that I could change to vary the size of the bar. ONE SOLUTION, TWO TECHNIQUES What s the best way to produce this HTML code? As it turns out, you can do it one of two ways. Using standard SAS code provides the most flexibility and customization, but requires a fair amount of code. ODS provides a very concise solution, but customization is difficult. Choose the one that most meets your needs Note: The gif file used in this presentation is available at http://www.cdc.gov/ncipc/images/red.gif SAS Code Technique Appendix A contains the SAS code used to produce the graphs above. It uses standard DATA STEP coding. While reading SAS code that produces HTML code may be challenging, the user might benefit from first generating the graph using an HTML editor like FrontPage and looking at the resulting HTML code. ODS Technique Figure 2 - Graphical Format Since implementation of the code mentioned above, I was told of another solution that used ODS (see Appendix B). While I ve not actually put the code in production it appears to be a viable alternative to the DATA STEP programming. It is included for your benefit, though there are likely things that you would change

before you would actually use this in production. BENEFITS There were several advantages to this approach: The graph could be put in a multi-column table which would let the bar be in one column and the labels be in another. This would allow the HTML table to control how the text of the label wrapped and ensured that it stayed with the horizontal bar. The application didn t have to control that, the browser did. It didn t require any knowledge of SAS/Graph or Annotate, and used standard SAS/IntrNet techniques. The resulting HTML file was small which would make downloads quicker. Instead of downloading a big graphic to your browser you end up downloading only a one-pixel.gif file which speeds response time. CONCLUSION Adding graphs to your web pages can make them have a much bigger impact on the user. Using the techniques discussed in this paper can make the job easier. REFERENCES SAS, SAS/Graph, and SAS/IntrNet are registered trademarks or trademarks of SAS Institute Inc. FrontPage is a registered trademark of Microsoft Corporation. ACKNOWLEDGMENTS I want to acknowledge that Steve Bloom told me about both of these techniques and has made my life much better by easing the process of adding graphics to my web application. I present them here only because he wasn t going to and I thought them too good not to share. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Steve James Centers for Disease Control and Prevention 4770 Buford Highway, MS-K59 Atlanta, GA 30341 Work Phone: (770) 488-4269 Fax: (770) 488-1665 Email: sjames@cdc.gov

APPENDIX A *-------------------------------------------------------------- * Prepare data for creating graphics. The output of this step * is a SAS data set with three variables: cause, deaths, and * percent. *-------------------------------------------------------------- proc freq data=temp tables cause / noprint out=totals(rename=count=deaths) weight deaths label cause='cause of Injury' deaths='number of Deaths' run *------------------------------------------------------------------------ * Now produce the chart as a table with three columns: one with the cause * of death, one with the number of deaths, and one with the percentage of * deaths including the bar chart. * The bar chart is drawn using a.gif that is one pixel in size, and uses * the WIDTH= and HEIGHT= options on the IMG tag to make it the right * size. Note: &DEATHS is a macro variable passed in that contains the * total number of deaths for all categories and is used in the title. *------------------------------------------------------------------------ data _null_ file _webout set work.totals end=lastob if _n_ = 1 then do put '<table border="0" cellpadding="2" width="771">' // '<tr>' / '<td width="132" height="27"><font face="arial">' '<b>cause of Death</b></font></td>' '<td nowrap><p align="right"><font size="2" face="arial">' '<b>number<br> of Deaths</b></font></td>' '<td width="18" height="27"></td>' '<td width="536" height="27">' '<font face="arial" size="2">' '<b>percentage of Deaths</b></font></td>' end * create quoted strings for height and width. Want them * to look like height="20" and width="44.5%" length height width $8 total 5 if percent < 1.0 then width=quote("1.0%") * set minimum width of bars at 1% else width = compress(quote(put(percent,5.2)!! '%')) height = quote("20")

total = &deaths put /* print out the cause of death */ '<tr>' '<td width="132" height="30"><font face="arial">' cause /* print out the number of deaths */ '<td width="61" height="30" align="right">' '<font face="arial">' deaths comma10. /* put spaces in column to hold it open */ '<td width="10" align="right"><font color="#ffffff" size="2" ' 'face="arial">' '<img src="http://www.cdc.gov/navimages/spacer.gif" width="5">' /* print out the percentage of deaths and the bar */ '<td width="538" height="30" align="left">' '<font face="arial">' '<img border="0" ' 'src="http://www.cdc.gov/ncipc/images/red.gif"' 'width=' width 'height=' height '>' '<img border="0" ' 'src="http://www.cdc.gov/navimages/spacer.gif" ' 'width="5">' percent 4.1 '%</font></td>' if lastob then do put '<tr>' '<td width="132" height="30"><font face="arial" size="2">' '<b>total Deaths&nbsp</b></font></td>' '<td width="85" height="30" colspan="2"><font size="2">' '<p align="right"></font><font size="2" face="arial"><b>' total comma10. '</b></font><font face="arial"> </font></td>' '<td width="536" height="30"></td>' put '</table>' end run APPENDIX B proc template edit Base.Freq.OneWayFreqs COLUMN Line Variable ListVariable Frequency TestFrequency bar Percent /* TestPercent CumFrequency CumPercent */ define bar HEADER=" " format=120.

just=l compute as Percent TRANSLATE _val_>0 into "<a><img SRC='http://www.cdc.gov/ncipc/images/red.gif' width=" put(_val_ * 10,4.) " height=10 ALT='' BORDER='0'>" put(_val_/100,percent8.1)!! "</a>" end end run ods listing close ods HTML file = "c:\temp\freq.html" * set up file to hold HTML code proc freq data=temp order=freq weight deaths table cause/ nocum run *------------------------------------------------------------- * Remove what you have done so it will not affect later freqs. *------------------------------------------------------------- Proc template Delete Base.Freq.OneWayFreqs Run ods HTML close