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

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

ABC Macro and Performance Chart with Benchmarks Annotation

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

The GSLIDE Procedure. Overview. About Text Slides CHAPTER 27

Picturing Statistics Diana Suhr, University of Northern Colorado

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

CHAPTER 7 Examples of Combining Compute Services and Data Transfer Services

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

A simplistic approach to Grid Computing Edmonton SAS Users Group. April 5, 2016 Bill Benson, Enterprise Data Scienc ATB Financial

MIS Reporting in the Credit Card Industry

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

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

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

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

PharmaSUG 2012 Paper CC13

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

Using PROC REPORT to Cross-Tabulate Multiple Response Items Patrick Thornton, SRI International, Menlo Park, CA

The GANNO Procedure. Overview CHAPTER 12

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

Out of Control! A SAS Macro to Recalculate QC Statistics

PharmaSUG Paper TT10 Creating a Customized Graph for Adverse Event Incidence and Duration Sanjiv Ramalingam, Octagon Research Solutions Inc.

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

A Juxtaposition of Tables and Graphs Using SAS /GRAPH Procedures

Open Problem for SUAVe User Group Meeting, November 26, 2013 (UVic)

SAS System Powers Web Measurement Solution at U S WEST

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

Trend Reporting Using the MXG Trend Performance Database

Validation Summary using SYSINFO

Tracking Dataset Dependencies in Clinical Trials Reporting

Contents of SAS Programming Techniques

The GREMOVE Procedure

Coders' Corner. Paper ABSTRACT GLOBAL STATEMENTS INTRODUCTION

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

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

How to annotate graphics

An Introduction to SAS Macros

A Way to Work with Invoice Files in SAS

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

Fly over, drill down, and explore

The GIMPORT Procedure

Divide and Conquer Writing Parallel SAS Code to Speed Up Your SAS Program

Report Writing, SAS/GRAPH Creation, and Output Verification using SAS/ASSIST Matthew J. Becker, ST TPROBE, inc., Ann Arbor, MI

Tips and Tricks in Creating Graphs Using PROC GPLOT

Innovative Graph for Comparing Central Tendencies and Spread at a Glance

The REPORT Procedure CHAPTER 32

Paper A Simplified and Efficient Way to Map Variable Attributes of a Clinical Data Warehouse

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

Posters. Workarounds for SASWare Ballot Items Jack Hamilton, First Health, West Sacramento, California USA. Paper

A Cross-national Comparison Using Stacked Data

The G3GRID Procedure. Overview CHAPTER 30

Top Award and First Place Best Presentation of Data Lan Tran-La. Scios Nova, Inc. BLOOD PRESSURE AND HEART RATE vs TIME

DBLOAD Procedure Reference

A Simple Framework for Sequentially Processing Hierarchical Data Sets for Large Surveys

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

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

The Power of PROC SQL Techniques and SAS Dictionary Tables in Handling Data

Useful Tips When Deploying SAS Code in a Production Environment

Using UNIX Shell Scripting to Enhance Your SAS Programming Experience

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

SAS Programming Basics

Splitting Axis Text. Splitting Text in Axis Tick Mark Values

ODS DOCUMENT, a practical example. Ruurd Bennink, OCS Consulting B.V., s-hertogenbosch, the Netherlands

Run your reports through that last loop to standardize the presentation attributes

Lab #1: Introduction to Basic SAS Operations

The GTESTIT Procedure

Regaining Some Control Over ODS RTF Pagination When Using Proc Report Gary E. Moore, Moore Computing Services, Inc., Little Rock, Arkansas

SparkLines Using SAS and JMP

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

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

ODS/RTF Pagination Revisit

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

Developing a Dashboard to Aid in Effective Project Management

Data Driven Annotations: An Introduction to SAS/GRAPH s Annotate Facility

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

10 The First Steps 4 Chapter 2

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

The %let is a Macro command, which sets a macro variable to the value specified.

Internet/Intranet, the Web & SAS

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

A Macro that can Search and Replace String in your SAS Programs

Enhancing SAS Piping Through Dynamic Port Allocation

WKn Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 9

Simplifying the Sample Design Process with PROC PMENU

A Practical and Efficient Approach in Generating AE (Adverse Events) Tables within a Clinical Study Environment

Introduction. Getting Started with the Macro Facility CHAPTER 1

ODS LAYOUT is Like an Onion

footnote1 height=8pt j=l "(Rev. &sysdate)" j=c "{\b\ Page}{\field{\*\fldinst {\b\i PAGE}}}";

Using PROC SQL to Calculate FIRSTOBS David C. Tabano, Kaiser Permanente, Denver, CO

Data Manipulation with SQL Mara Werner, HHS/OIG, Chicago, IL

Intermediate SAS: Working with Data

QUEST Procedure Reference

INTRODUCTION TO THE SAS ANNOTATE FACILITY

Routing Output. Producing Output with SAS Software CHAPTER 6

Windows: SPX Access Method

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

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

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

Desktop Studio: Charts. Version: 7.3

Essential ODS Techniques for Creating Reports in PDF Patrick Thornton, SRI International, Menlo Park, CA

Base and Advance SAS

Transcription:

Paper 111-25 Scaling Mount GCHART: Using a MACRO to Dynamically Reset the Scale Nina L. Werner, Dean Health Plan, Inc., Madison, WI ABSTRACT If you do not set the scale yourself, PROC GCHART will automatically change the scale of the X-axis to match the unique data that happen to appear on each individual page. Conversely, if you set a scale, every page will have the same static value, regardless of the actual data values appearing in it. Neither was acceptable for this application. Using DATA step programming and a MACRO, I can dynamically reset the scale of a stacked bar chart s X-axis to a logical value for each new department while maintaining that same scale for multiple pages within the department, producing charts with the look you want. INTRODUCTION Three annotated SASŸ programs (version 6.12) are presented. In addition to the method of setting the scale for each department and the MACRO which applies it to GCHART, they also contain other programming techniques of interest. They demonstrate the use of RSUBMIT to retrieve data from Sybase using SAS/CONNECTŸ SAS/ACCESSŸ to Sybase and PROC DOWNLOAD, using macro variables for data selection passed from local (Windows) to remote (UNIX) SAS sessions. Data is summed as it is selected using nested SELECT statements in PASSTHRU SQL, so the summarization takes place inside Sybase. Data transformation is performed to allow stacked bars to be displayed side-by-side. A dummy sort variable is created to control page breaks for a consistent look. Formats are used on variables invoked in GCHART to order and label values. Program Listing for Submit: RVUCHART.SAS * -- * -- * -- %LET m = 06 %LET l = 98 %LET c = 99 * -- * -- * -- SIGNON * Connect to UNIX LIBNAME rvu 'C:\UserData\SAS\Data' %INCLUDE 'C:\UserData\SAS\Programs\syslput.sas' %syslput(mo,&m) %syslput(lyr,&l) %syslput(cyr,&c) %INCLUDE 'C:\UserData\SAS\Programs\rvu-cht.sas' %INCLUDE 'C:\UserData\SAS\Programs\rvu-mac.sas' * RVUCHART.SAS --(LANDSCAPE,SASMONO,10 POINT) DISCUSSION OF SUBMIT PROGRAM RVUCHART.SAS shows the code brought into the Editor Window for submission. The requester needs to overtype the three macro fields on line 2, m (month), l (last year), and c (current year.) SIGNON command invokes SAS CONNECT to remote UNIX, requires entry of UNIX userid and password. LIBNAME rvu sets location of retrieved data in Windows (local) for SAS/GRAPHŸ. SYSLPUT MACRO sends local macro variables (m, l, c) to remote macro variables (mo, lyr, cyr.) Two %INCLUDE statements run the data-selection and graph-production programs. Using %INCLUDE shields the program source code from accidental editing by the requester. The source is separated into two sections so that after successful data extraction, the SAS/GRAPH program may be repeated if necessary without having to return to UNIX. Windows Printer Setup must be set to Landscape, SASMONO font, 10-point before submitting. First Included Program Listing: RVU-CHT.SAS RSUBMIT * RVU-CHT.SAS -- Nina L. Werner OPTIONS NOCENTER DATE NUMBER PROC SQL CONNECT TO SYBASE (user=nina password=zzzzzzzz database=rvu_data server=sybsrver ) CREATE TABLE curr AS SELECT DISTINCT ins_type, cytd, lytd (SELECT ins_type, (SELECT SUM(e.amount) FROM dbo.rvu e WHERE e.gl_month <= "&mo" AND e.gl_year = "&cyr" AND e.doc_num = r.doc_num AND e.injection = r.injection AND e.ins_type = r.ins_type) AS cytd, (SELECT SUM(f.amount) FROM dbo.rvu f WHERE f.gl_month <= "&mo" AND f.gl_year = "&lyr" AND f.doc_num = r.doc_num AND f.injection = r.injection AND f.ins_type = r.ins_type) AS lytd FROM dbo.rvu r WHERE doc_num < 20000 AND injection IN ('N') AND ins_type IN ('H','N') ORDER BY ins_type, doc_num) CREATE TABLE doc AS SELECT name, INPUT(docno, 5.) AS INPUT (dept, 5.) AS dept (SELECT * FROM dbo.doc_ref WHERE docno < '20000' ORDER BY dept, docno)

CREATE TABLE dpt AS SELECT dept_nam, INPUT (dept_num, 5.) AS dept (SELECT * FROM dbo.dept_ref WHERE dept_ancil = D ORDER BY dept_num) DISCONNECT FROM SYBASE QUIT RUN PROC SQL CREATE TABLE dmcref AS SELECT dpt.dept, dept_nam, name FROM doc LEFT JOIN dpt ON doc.dept = dpt.dept ORDER BY dept, doc_num QUIT RUN DATA current (="RVU H/N D &mo/&cyr") SET curr IF SUM (0, cytd, lytd) ^= 0 difyr = (cytd - lytd) / lytd difyr = 'Annual incr/decr' cytd = 'Current Year to Date' lytd = 'Last Year to Date' ins_type = 'HMO or Fee for Service' RUN PROC SQL CREATE TABLE chart AS SELECT n.dept_nam, n.dept, r.ins_type, n.name, r. r.cytd, r.lytd, r.difyr FROM current r LEFT JOIN dmcref n ON r.doc_num = n.doc_num ORDER BY dept_nam, ins_type, name QUIT DATA chart (="RVU H/N D &mo/&cyr") SET chart dept = 'dept_num' dept_nam = 'Department' name = 'Provider Name' RUN PROC SORT DATA=chart BY dept_nam name ins_type RUN PROC DOWNLOAD IN=work OUT=rvu MEMTYPE=DATA SELECT chart QUIT RUN ENDRSUBMIT SIGNOFF * ############################################ OPTIONS SOURCE2 PROC SORT DATA=rvu.chart OUT=cht1 BY doc_num RUN PROC MEANS N MAX NOPRINT DATA=cht1 OUTPUT OUT=docmax N=n MAX=maxc maxl VAR cytd lytd BY doc_num RUN DATA zero (KEEP= doc_num) SET docmax WHERE maxc<=0 & maxl<=0 RUN DATA cht2 MERGE cht1 zero (IN=inz) BY doc_num IF ^inz RUN /* create formats for chart text */ PROC FORMAT LIB=library VALUE $ins 'H' = ' HMO ' 'N' = 'Fee for Service' VALUE $ytd 'C' = 'Current' 'L' = 'Last ' RUN DATA ch3 SET cht2 LENGTH ytd_flag $1. amount = cytd ytd_flag = 'C' OUTPUT amount = lytd ytd_flag = 'L' OUTPUT FORMAT ins_type $ins. ytd_flag $ytd. amount = 'Production' dept = 'dept_num' ytd_flag = 'Current/Last YTD' RUN PROC SORT DATA=ch3 BY dept_nam name ins_type RUN DATA rvu.chartrvu (="RVU H/N D &m/&y" DROP=seq cytd lytd ancil difyr) SET ch3 LENGTH page seq 3 RETAIN page seq 0 BY dept_nam name IF cytd < 0 THEN cytd = 0 IF lytd < 0 THEN lytd = 0 IF FIRST.dept_nam THEN DO page = 1 seq = 0 END IF FIRST.name THEN seq +1 /* 8 names per page */ IF seq = 9 THEN DO seq = 1 page +1 END page = 'Page number' RUN PROC SORT DATA=rvu.chartrvu BY dept_nam page name ins_type RUN

DISCUSSION OF DATA RETRIEVAL PROGRAM RVU-CHT.SAS is the data extract, the first included program. It contains RSUBMIT-ENDRSUBMIT section which is executed in UNIX to retrieve Sybase data and download it back to Windows, plus a local section which runs in Windows. PASSTHRU SQL code passes the values of remote macro variables for conditional data selection in the first CREATE TABLE. Nested SELECT statements join Sybase table rvu with itself to summarize current year-to-date and last year-to-date totals by doctor number, injection flag and insurance type, for subsetting conditions. Two other CREATE TABLE SELECTs make reference tables for doctor name and department name. Department and doctor ID fields are converted from character to numeric in these reference tables to match detail ( rvu ) data. DISCONNECT FROM SYBASE delimits the end of Sybase access, however, the process is still running on the remote (UNIX) platform. The two reference tables are combined using LEFT JOIN in PROC SQL. Since cytd and lytd are dollar fields created by summing detail records where they may be positive or negative, doctor records where the values are both zero or add to zero (cancel each other out) are omitted now. The percent difference between this year and last year is calculated. Names are applied to remaining detail records using LEFT JOIN in PROC SQL. The data are sorted by department and doctor names instead of Ids, and labels are applied. The data set chart is passed to Windows by PROC DOWNLOAD. Connection to UNIX is severed, removing WORK datasets created on the UNIX platform. The rest of the processing occurs in Windows. PROC MEANS is used to capture the maximum values for current year-to-date and last year-to-date for each doctor between his two records (insurance type = HMO H or not N.) Doctors with negative or zero maximums are omitted here. Formats are created. Note that $ins is set to HMO or Fee for Service to maintain desired order of items blank-h will appear before Fe... Data is transformed so that instead of two records per doctor by insurance type, each with current year-to-date and last year-to-date fields, four records per doctor by insurance type and ytd-flag are written. The dollar fields are collapsed to one variable amount to display side-by-side bars. As the permanent SAS dataset rvu.chartrvu is created, negative values are set to zero, so no bar will display a negative value. A new variable page is created to make even page breaks on the bar graphs. Page number starts over with a value of one for each department and is incremented after eight doctor names per page. Note the use of the local macro variables in the dataset s label. The permanent SAS dataset is sorted into its final order for graphical presentation, BY dept_nam page name ins_type. Second Included Program Listing: RVU-MAC.SAS * RVU-MAC.SAS -- Nina L. Werner * SAS monospace 10 pt Landscape OPTIONS CENTER NODATE NONUMBER NOBYLINE MISSING='0' LS=126 PS=42 *OPTIONS MACROGEN MPRINT SYMBOLGEN /* calculate departmental maximums for X-axis of graphs */ PROC MEANS N MAX NOPRINT DATA=rvu.chartrvu OUTPUT OUT=deptmax N=n MAX=max1 VAR amount BY dept_nam RUN DATA maximums (KEEP= dept_nam max int) SET deptmax WHERE max1 > 0 maxi = max1 *2 IF maxi < 9999 THEN DO max = ROUND(maxi, 100) max + 100 int = ROUND( (max/5), 10) END ELSE IF maxi < 99999 THEN DO max = ROUND(maxi, 1000) max + 1000 int = ROUND( (max/5), 100) END ELSE DO max = ROUND(maxi, 10000) max + 10000 int = ROUND( (max/5), 1000) END int = 'X-axis Interval' max = 'X-axis Maximum' max1 = 'Dept Max Bar Len' maxi = 'Dept Dbl Bar Len' RUN ********************************************** /* macro to repeat chart for each department with separate scale */ %MACRO deptchrt DATA _NULL_ SET maximums END=last ('dpt' TRIM(LEFT(PUT(_N_,3.))), TRIM(dept_nam)) ('max' TRIM(LEFT(PUT(_N_,3.))), TRIM(LEFT(max))) ('int' TRIM(LEFT(PUT(_N_,3.))), TRIM(LEFT(int))) IF last THEN ('num',trim(left(put(_n_,3.)))) RUN %PUT >>>>&num Departments for &m/&c on %SYSFUNC(TODAY(),WORDDATE18)<<<< %DO i=1 %TO &num GOPTIONS RESET=GLOBAL GOPTIONS DEVICE=HPGL4SI /* WIN */ GUNIT=PCT FTEXT=SIMPLEX CTEXT=BLACK CBACK=WHITE HTITLE=4 HTEXT=1.5 HPOS=120 VPOS=45 PATTERN1 VALUE=SOLID COLOR=BLACK PATTERN2 VALUE=X1 COLOR=BLACK FOOTNOTE J=R COLOR=BLACK FONT=SWISSB "%SYSFUNC(TODAY(), WORDDATE18)"

LEGEND CBORDER=BLACK CSHADOW=BLACK OFFSET=(5,0) =NONE AXIS1 COLOR=BLACK =(FONT=SWISSXB 'Production Total by Provider') ORDER=(0 TO &&max&i BY &&int&i) AXIS2 COLOR=BLACK AXIS3 =(FONT=SWISSXB 'PROVIDER NAME') COLOR=BLACK =(FONT=SWISSXB 'YTD ') TITLE1 HEIGHT=3 FONT=SWISSB 'Dean Medical Center, S.C.' TITLE2 HEIGHT=4 FONT=SWISSB 'Total Provider Production: HMO and Fee For Service' TITLE3 HEIGHT=3 FONT=SWISSB "#BYVAL(dept_nam) - Current Month &m/&c - " "Page #BYVAL(page)" PROC GCHART DATA=rvu.chartrvu HBAR ytd_flag / GROUP=name SUBGROUP=ins_type SUMVAR=amount SUM DISCRETE TYPE=SUM RAXIS=AXIS1 GAXIS=AXIS2 MAXIS=AXIS3 MINOR=4 WIDTH=1 SPACE=.1 AUTOREF CLIPREF LEGEND=LEGEND WHERE dept_nam = "&&dpt&i" BY dept_nam page FORMAT amount COMMA11.0 RUN QUIT %END RUN %MEND deptchrt ********************************************** /* invocation of macro to produce charts for each department */ %deptchrt DISCUSSION OF GRAPH MACRO PROGRAM RVU-MAC.SAS is the second included program, which first calculates the scale for each department if the departmental maximum is greater than zero into a SAS dataset called maximums. This includes the maximum size of the X-axis, which is double the maximum bar size, since bars will be stacked for insurance type within year, and a rounded value of 1/5 of this maximum for interval tick marks. Then, the MACRO program code appears. DATA _NULL_ is used to retrieve all the departmental values into a series of macro variables to pass each department s name, X-axis maximum value and interval value using. The MACRO reports to the SAS LOG on how many departments &num appear for the current selected month and year-to-date. Next, it will run PROC GCHART &num times with macro variables to adjust the current department s X-axis = 0 TO max BY int while leaving all other options consistent for all pages. GOPTIONS DEVICE=HPGL4SI sends charts directly to the printer. Alternatively, DEVICE=WIN would send charts to screen. The department name and page variable are captured into the title using #BYVAL and the month and current year-to-date are retrieved from the local macro variables. PROC GCHART sets two stacked (insurance type) bars side-by-side (ytd-flag) for each of the eight doctors per page, within the current department. The last step invokes the MACRO once to produce bar charts for all departments. The requester does not need to send each department to the printer individually. Figure 1 contains four typical graphs for three departments, demonstrating a different scale for each department, maintained over multiple pages within a department, when necessary. TRADEMARK CITATION 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. Other brand and product names are registered trademarks or trademarks of their respective companies. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Nina L. Werner, BA, MBA, MHP Dean Health Plan, Inc. 1277 Deming Way Madison, WI 53717 Work Phone: (608) 827-4224 Fax: (608) 836-6335 Email: Werner_Nina_L@ssmhc.com

Figure 1. Sample Graphs for Three Departments Coders' Corner