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

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

Coders' Corner. Scaling Mount GCHART: Using a MACRO to Dynamically Reset the Scale Nina L. Werner, Dean Health Plan, Inc., Madison, WI.

The GREMOVE Procedure

A SAS Macro to Generate Caterpillar Plots. Guochen Song, i3 Statprobe, Cary, NC

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

Picturing Statistics Diana Suhr, University of Northern Colorado

A Methodology for Truly Dynamic Prompting in SAS Stored Processes

Splitting Axis Text. Splitting Text in Axis Tick Mark Values

Ditch the Data Memo: Using Macro Variables and Outer Union Corresponding in PROC SQL to Create Data Set Summary Tables Andrea Shane MDRC, Oakland, CA

Chapter 13 Introduction to Graphics Using SAS/GRAPH (Self-Study)

ABC Macro and Performance Chart with Benchmarks Annotation

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

Developing a Dashboard to Aid in Effective Project Management

The GANNO Procedure. Overview CHAPTER 12

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

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

Usinq the VBAR and BBAR statements and the TEMPLATE Facility to Create side-by-side, Horizontal Bar Charts with Shared Vertical Axes Labels

Creating Maps in SAS/GRAPH

Maintaining a 'Look and Feel' throughout a Reporting Package Created with Diverse SAS Products Barbara B Okerson, Anthem, Inc.

How to annotate graphics

Trend Reporting Using the MXG Trend Performance Database

Super boost data transpose puzzle

Creating Forest Plots Using SAS/GRAPH and the Annotate Facility

It s Not All Relative: SAS/Graph Annotate Coordinate Systems

Figure 1. Paper Ring Charts. David Corliss, Marketing Associates, Bloomfield Hills, MI

Purpose: This chapter demonstrates how to create pie charts, and discusses some of the issues to consider when deciding whether to use a pie chart.

The GIMPORT Procedure

%MAKE_IT_COUNT: An Example Macro for Dynamic Table Programming Britney Gilbert, Juniper Tree Consulting, Porter, Oklahoma

Six Cool Things You Can Do In Display Manager Jenine Milum, Charlotte, NC Wachovia Bank

CREATING DRILL-DOWN GRAPHS USING SAS/GRAPH AND THE OUTPUT DELIVERY SYSTEM Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

Coders' Corner. Paper ABSTRACT GLOBAL STATEMENTS INTRODUCTION

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

Tips to Customize SAS/GRAPH... for Reluctant Beginners et al. Claudine Lougee, Dualenic, LLC, Glen Allen, VA

Archer R. Gravely, UNC Asheville, Asheville, NC

The Power of Combining Data with the PROC SQL

The G3GRID Procedure. Overview CHAPTER 30

Contents of SAS Programming Techniques

OS/390 DASD I/O Drill Down Computer Performance Chart Using ODS SAS/GRAPH & MXG Software

Time Contour Plots. David J. Corliss Magnify Analytic Solutions, Detroit, MI

Paper Time Contour Plots. David J. Corliss, Wayne State University / Physics and Astronomy

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

A Practical Introduction to SAS Data Integration Studio

Data Explore Matrix Quality Control by Exploring and Mining Data in Clinical Study

Clinical Data Visualization using TIBCO Spotfire and SAS

SAS CLINICAL SYLLABUS. DURATION: - 60 Hours

What s New in SAS Studio?

Innovative Graph for Comparing Central Tendencies and Spread at a Glance

CMISS the SAS Function You May Have Been MISSING Mira Shapiro, Analytic Designers LLC, Bethesda, MD

SAS Graphics & Code. stat 480 Heike Hofmann

FILLPATTERNS in SGPLOT Graphs Pankhil Shah, PPD, Morrisville, NC

100 THE NUANCES OF COMBINING MULTIPLE HOSPITAL DATA

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

SUGI 29 Posters. Paper A Group Scatter Plot with Clustering Xiaoli Hu, Wyeth Consumer Healthcare., Madison, NJ

Give me EVERYTHING! A macro to combine the CONTENTS procedure output and formats. Lynn Mullins, PPD, Cincinnati, Ohio

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

NEW FEATURES IN FOUNDATION SAS 9.4 CYNTHIA JOHNSON CUSTOMER LOYALTY

Paper TS05. NOTE: To keep the paper compact, screen images have usually been clipped to show only the essential parts of the displayed result.

ABSTRACT INTRODUCTION

Canadian National Longitudinal Survey of Children and Youth (NLSCY)

Fly over, drill down, and explore

From Manual to Automatic with Overdrive - Using SAS to Automate Report Generation Faron Kincheloe, Baylor University, Waco, TX

PDQ-Notes. Reynolds Farley. PDQ-Note 3 Displaying Your Results in the Expert Query Window

PharmaSUG 2013 CC26 Automating the Labeling of X- Axis Sanjiv Ramalingam, Vertex Pharmaceuticals, Inc., Cambridge, MA

ERROR: ERROR: ERROR:

Converting Annotate to ODS Graphics. Is It Possible?

Quality Control of Clinical Data Listings with Proc Compare

Ready To Become Really Productive Using PROC SQL? Sunil K. Gupta, Gupta Programming, Simi Valley, CA

Setting the Percentage in PROC TABULATE

Using SAS/GRAPH Software to Analyze Student Study Habits. Bill Wallace Computing Services University of Saskatchewan

Taming a Spreadsheet Importation Monster

%Addval: A SAS Macro Which Completes the Cartesian Product of Dataset Observations for All Values of a Selected Set of Variables

Breaking up (Axes) Isn t Hard to Do: An Updated Macro for Choosing Axis Breaks

SESUG 2014 IT-82 SAS-Enterprise Guide for Institutional Research and Other Data Scientists Claudia W. McCann, East Carolina University.

Programming Gems that are worth learning SQL for! Pamela L. Reading, Rho, Inc., Chapel Hill, NC

IPUMS Training and Development: Requesting Data

OLAP Drill-through Table Considerations

Using Big Data to Visualize People Movement Using SAS Basics

How to extract suicide statistics by country from the. WHO Mortality Database Online Tool

Chapters 18, 19, 20 Solutions. Page 1 of 14. Demographics from COLLEGE Data Set

APPENDIX 4 Migrating from QMF to SAS/ ASSIST Software. Each of these steps can be executed independently.

29 Shades of Missing

Want Quick Results? An Introduction to SAS/GRAPH Software. Arthur L. Carpenter California Occidental Consultants

INTRODUCTION TO THE SAS ANNOTATE FACILITY

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

Customized Flowcharts Using SAS Annotation Abhinav Srivastva, PaxVax Inc., Redwood City, CA

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

Teaching statistics and the SAS System

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

CIP (International Potato Center, part of the Consultative Group on International Agricultural Research)

A Plot & a Table per Page Times Hundreds in a Single PDF file

SAS/Warehouse Administrator Usage and Enhancements Terry Lewis, SAS Institute Inc., Cary, NC

Mapping Clinical Data to a Standard Structure: A Table Driven Approach

PharmaSUG China. Systematically Reordering Axis Major Tick Values in SAS Graph Brian Shen, PPDI, ShangHai

PREREQUISITES FOR EXAMPLES

PROC REPORT Basics: Getting Started with the Primary Statements

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

Paper # Jazz it up a Little with Formats. Brian Bee, The Knowledge Warehouse Ltd

ABSTRACT. This paper will focus on two of these pieces: ODS (Output Delivery System) SASlIntrNet

SAS/GRAPH : Using the Annotate Facility

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

Transcription:

SESUG 1994 Creating Population Tree Charts (Using SAS/GRAPH Software) Robert E. Allison, Jr. and Dr. Moon W. Suh College of Textiles, N. C. State University ABSTRACT This paper describes a SAS program that can be used to generate tree charts of US population data (or projections) to compare any year/state/sex/race combination on the left side of the tree against any year/state/sex/race combination on the right side. INTRODUCTION Tree charts are often used to analyze Census population projections. This paper describes a SAS program which can be used to compare any two population groups. The program provides the versatility to allow users to easily select any state, year, race and sex on the left side of the tree, and compare it to any state, year, race and sex on the right side of the tree chart. The code used in this example was developed as part of the Textile and Apparel Business Information System (TABIS). It is based on the principles presented in Example 17 of the SAS/GRAPH Examples manual. To fully utilize this sample program, users will need to have access to population data stored in a SAS data set called pop using the variables listed below. (For those who do not have access to such data, a data step with sample data is included in Appendix A.) STATE char postal abbr. (eg. 'NC', 'SC', etc.) YEAR numeric (eg. 1990) RACE numeric (eg. 0=all, 1=white, 2=black) SEX numeric (eg. 0=both, 1=male, 2=female) AGE0 numeric (number of people age 0) AGE1 numeric (number of people age 1) AGE98 numeric (number of people age 98) AGE99 numeric (number of people age 99 and over) SAMPLE CODE To facilitate easily selecting the year, state, sex and race for the two sides of the tree chart, the following macro variables are defined. The variables beginning with an "l_" are used for the left side of the tree, and the variables beginning with an "r_" denote values for the right side. %let l_year=1990; %let r_year=2010; %let l_state='us'; %let r_state='us'; %let l_sex=2; %let r_sex=2; %let l_race=0; %let r_race=0; 1

The population trees in this example split the population into 20 age groups, each covering a 5 year range. The following SAS SQL code groups the data in this manner, and stores it as G01 G20. The variable names are important since the PROC GCHART's HBAR chart arranges the bars in alphabetical order based on the variable name. G00 is a "dummy" variable used to add extra space at the top of the tree chart. proc sql; create table pop2 as select unique year, state, sex, race, sum( AGE0, AGE1, AGE2, AGE3, AGE4 ) as g20, sum( AGE5, AGE6, AGE7, AGE8, AGE9 ) as g19, sum( AGE10, AGE11, AGE12, AGE13, AGE14 ) as g18, sum( AGE15, AGE16, AGE17, AGE18, AGE19 ) as g17, sum( AGE20, AGE21, AGE22, AGE23, AGE24 ) as g16, sum( AGE25, AGE26, AGE27, AGE28, AGE29 ) as g15, sum( AGE30, AGE31, AGE32, AGE33, AGE34 ) as g14, sum( AGE35, AGE36, AGE37, AGE38, AGE39 ) as g13, sum( AGE40, AGE41, AGE42, AGE43, AGE44 ) as g12, sum( AGE45, AGE46, AGE47, AGE48, AGE49 ) as g11, sum( AGE50, AGE51, AGE52, AGE53, AGE54 ) as g10, sum( AGE55, AGE56, AGE57, AGE58, AGE59 ) as g09, sum( AGE60, AGE61, AGE62, AGE63, AGE64 ) as g08, sum( AGE65, AGE66, AGE67, AGE68, AGE69 ) as g07, sum( AGE70, AGE71, AGE72, AGE73, AGE74 ) as g06, sum( AGE75, AGE76, AGE77, AGE78, AGE79 ) as g05, sum( AGE80, AGE81, AGE82, AGE83, AGE84 ) as g04, sum( AGE85, AGE86, AGE87, AGE88, AGE89 ) as g03, sum( AGE90, AGE91, AGE92, AGE93, AGE94 ) as g02, sum( AGE95, AGE96, AGE97, AGE98, AGE99 ) as g01, 0 as g00 from pop order by year, state, sex, race; quit; proc transpose The data set must next be transposed so that the G00-G20 variable names become values. The following code performs this task, and then converts the population values into millions. proc transpose data=pop2 out=pop2; by year state sex race; proc datasets; modify pop2; rename _name_=age_grp; rename COL1=pop; data pop2; set pop2; pop=pop/1000000; The macro variables are used in the "WHERE" clauses of the following SAS SQL queries to select the desired data, and place it into the "left" and "right" data sets. These two data sets are then joined into a data set called "both". Notice that the values in the left data set are negative this forces GCHART to add a zero reference line, and draw the bars for those values to the left of the line. proc sql; create table left as select unique age_grp, year, state, sex, race, (-1*pop) as pop, 'left ' as group from pop2 where (year=&l_year) and (state=&l_state) and (sex=&l_sex) and (race=&l_race); 2

create table right as select unique age_grp, year, state, sex, race, pop, 'right' as group from pop2 where (year=&r_year) and (state=&r_state) and (sex=&r_sex) and (race=&r_race); quit; data both; set left right; If you do not have access to Census data, you can use the code in Appendix A instead of the previous code to create a sample "both" data set. The following code prepares several of the visual aspects of the chart to make it more readable. In axis1, the "posval" format forces the labels for the negative values to print as positive values. In axis2, a label for each group is specified. The title2 and title3 statements help document which values were selected for the left and right sides of the tree chart. goptions reset=global gunit=pct rotate=landscape htitle=4 htext=2.5 ftitle=zapfb ftext=zapf cback=white ctext=black colors=(black); proc format; picture posval low-high='000,009'; axis2 label=('in Millions') major=(number=7); axis1 label=none value=( ' Age ' '95+ ' '90-94' '85-89' '80-84' '75-79' '70-74' '65-69' '60-64' '55-59' '50-54' '45-49' '40-44' '35-39' '30-34' '25-29' '20-24' '15-19' '10-14' ' 5-9 ' ' 0-4 ') ; Title1 "Population Distribution"; title2 "Left : state=&l_state race=&l_race sex=&l_sex year=&l_year"; title3 "Right: state=&r_state race=&r_race sex=&r_sex year=&r_year"; The remaining code creates the tree chart: proc gchart data=both; format pop posval.; hbar age_grp / discrete type=sum sumvar=pop nostats space=0 subgroup=group nolegend frame autoref maxis=axis1 raxis=axis2 cframe=white coutline=black caxis=black; EXAMPLES In tree charts, it is customary to have all the values on the left and right be the same, except for the one variable that is being compared. The variable most often compared is sex (male versus female). The following four examples demonstrate that this program can be used to compare many combinations of variables: 3

4

5

APPENDIX A. SAMPLE DATA data both; input age_grp $ year state $ sex race pop group $; cards; G00 2010 US 1 0 0.0000 left G01 2010 US 1 0-0.1315 left G02 2010 US 1 0-0.4716 left G03 2010 US 1 0-1.2243 left G04 2010 US 1 0-2.3194 left G05 2010 US 1 0-3.2551 left G06 2010 US 1 0-4.1466 left G07 2010 US 1 0-5.5966 left G08 2010 US 1 0-7.5048 left G09 2010 US 1 0-9.0983 left G10 2010 US 1 0-10.5797 left G11 2010 US 1 0-11.0508 left G12 2010 US 1 0-10.0828 left G13 2010 US 1 0-9.5373 left G14 2010 US 1 0-9.1250 left G15 2010 US 1 0-9.8663 left G16 2010 US 1 0-10.6530 left G17 2010 US 1 0-11.5039 left G18 2010 US 1 0-10.6329 left G19 2010 US 1 0-10.1170 left G20 2010 US 1 0-10.2617 left G00 2010 US 1 0 0.0000 right G01 2010 US 1 0 0.4669 right G02 2010 US 1 0 1.1956 right G03 2010 US 1 0 2.3095 right G04 2010 US 1 0 3.4597 right G05 2010 US 1 0 4.1232 right G06 2010 US 1 0 4.8876 right G07 2010 US 1 0 6.3471 right G08 2010 US 1 0 8.2018 right G09 2010 US 1 0 9.7470 right G10 2010 US 1 0 11.0885 right G11 2010 US 1 0 11.3802 right G12 2010 US 1 0 10.3132 right G13 2010 US 1 0 9.7254 right G14 2010 US 1 0 9.2967 right G15 2010 US 1 0 9.8910 right G16 2010 US 1 0 10.3227 right G17 2010 US 1 0 10.8945 right G18 2010 US 1 0 10.0913 right G19 2010 US 1 0 9.6054 right G20 2010 US 1 0 9.7556 right ; CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Name: Robert Allison Enterprise: SAS E-mail: Robert.Allison@sas.com SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. 6