The gchart Procedure The gchart Procedure is used to create bar charts of various types (it can also create pie charts. It’s most basic form would look.

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Step-by-Step: Adjust a Chart Axis USE the Pricing Final presentation that is still open from the previous exercise. 1.Click the chart on slide 2 to select.
Chapter 3 Graphic Methods for Describing Data. 2 Basic Terms  A frequency distribution for categorical data is a table that displays the possible categories.
Fundamental Features of Graphs All graphs have two, clearly-labeled axes that are drawn at a right angle. –The horizontal axis is the abscissa, or X-axis.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
1 Describing Quantitative Data Here we study ways of describing a variable that is quantitative.
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
1 Computing for Todays Lecture 10 Yumei Huo Fall 2006.
XP New Perspectives on Microsoft Office Excel 2003 Tutorial 1 1 Microsoft Office Excel 2003.
SW318 Social Work Statistics Slide 1 Using SPSS for Graphic Presentation  Various Graphics in SPSS  Pie chart  Bar chart  Histogram  Area chart 
1 Good graphs & charts using Excel Module 1 Session 7.
XP New Perspectives on Microsoft Office Excel 2003 Tutorial 4 1 Microsoft Office Excel 2003 Tutorial 4 – Working With Charts and Graphics.
CHAPTER 1: Picturing Distributions with Graphs
Introduction to Excel 2007 Part 3: Bar Graphs and Histograms Psych 209.
AP Statistics Day One Syllabus AP Content Outline Estimating Populations and Subpopulations.
Frequency Distributions and Graphs
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
CHAPTER 14 Formatting a Workbook Part 1. Learning Objectives Format text, numbers, dates, and time Format cells and ranges CMPTR Chapter 14: Formatting.
Drill-down Graphs By Heather Hoffman. Family Practice Department Project  Create drill-down graphs that depict % of patients for each CCS* over a given.
Introduction to SAS Essentials Mastering SAS for Data Analytics
STATISTICAL GRAPHS.
PROC GREPLAY With Templates December 5, 2008 Barry Hong Process Analysis and Simulation U. S. Steel Canada © 2008 United States Steel Corporation.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Chapter 5: Charts Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Examples of different formulas and their uses....
The introduction to SPSS Ⅱ.Tables and Graphs for one variable ---Descriptive Statistics & Graphs.
Microsoft Office Illustrated Introductory, Premium Edition with Charts Working.
Sullivan – Fundamentals of Statistics – 2 nd Edition – Chapter 2 Section 1 – Slide 1 of 27 Chapter 2 Section 1 Organizing Qualitative Data.
 Frequency Distribution is a statistical technique to explore the underlying patterns of raw data.  Preparing frequency distribution tables, we can.
In this chapter, we will look at some charts and graphs used to summarize categorical data.
A Picture Is Worth A Thousand Words. DAY 7: EXCEL CHAPTER 4 Tazin Afrin September 10,
Microsoft ® Office Excel 2007 Working with Charts.
Statistics Unit 2: Organizing Data Ms. Hernandez St. Pius X High School
Dot Plots and Histograms Lesson After completing this lesson, you will be able to say: I can create a dot plot and histogram to display a set of.
Excel – Lesson 2 Excel Lesson 2 Changing the Appearance of a Worksheet Microsoft Office 2007: Introductory Pasewark & Pasewark 1.
When data is collected from a survey or designed experiment, they must be organized into a manageable form. Data that is not organized is referred to as.
Session 9 Managerial Spreadsheet Modeling -- Prof. Juran1.
2010 Staff Development - Tony Judice. Highlight the area to be graphed. Highlight labels, in this case days of the week, and the values that apply to.
Chapter 5 Working with Multiple Worksheets and Workbooks
Creating Graphs in PowerPoint Step 1 Open a new PowerPoint Document.
PROC GPLOT GPLOT is used to make two dimensional scatter-plots. General Syntax: proc gplot data=data-set options; plot y-variable*x-variable/options; run;
1. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
Chapter 15: Spreadsheet and Worksheet Basics Lesson 96: Worksheets with Charts © 2010, 2006 South-Western, Cengage Learning.
Chapter 3: Organizing Data. Raw data is useless to us unless we can meaningfully organize and summarize it (descriptive statistics). Organization techniques.
Copyright 2011 by W. H. Freeman and Company. All rights reserved.1 Introductory Statistics: A Problem-Solving Approach by Stephen Kokoska Chapter 2 Tables.
Types of Graphs and Graphing Rules
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Graphing A step by step method. Line Graphs  A line graph is a style of chart that is created by connecting a series of data points together with a line.
CMS SAS Users Group Conference Learn more about THE POWER TO KNOW ® October 17, 2011 PROC GMAP, HTML and You Thomas Kornfield, CMS.
AP Statistics Objective: Students will be able to construct and determine when to use bar charts, pie charts, and dot plots. (Histograms)
Copyright © 2009 Pearson Education, Inc. 3.2 Picturing Distributions of Data LEARNING GOAL Be able to create and interpret basic bar graphs, dotplots,
SOC 305, Prof. Robert Martin Southeastern Louisiana University.
The Diminishing Rhinoceros & the Crescive Cow
Organizing Qualitative Data
Excel Chapter 1 Review Slides
Created by Stacey Wilson
Probability & Statistics Displays of Quantitative Data
Excel Part 4 Working with Charts and Graphics
QM222 A1 Visualizing data using Excel graphs
Excel Part 4 Working with Charts and Graphics
Formatting a Workbook Part 1
exploring Microsoft Office 2013 Plus
Organizing Qualitative Data
Excel Part 4 Working with Charts and Graphics
Let’s review some of the statistics you’ve learned in your first class: Univariate analyses (single variable) are done both graphically and numerically.
Presentation transcript:

The gchart Procedure The gchart Procedure is used to create bar charts of various types (it can also create pie charts. It’s most basic form would look something like this: proc gchart data=save.padgett; vbar plantht; run; quit;

The gchart Procedure The vbar (or hbar) statement includes a variable that is referred to as the midpoint variable. If this variable is of the character type, a midpoint is established for each unique value. If it is numeric, SAS establishes classes or bins for it. In either case, the frequency in each class is summarized by vertical (or horizontal) bars.

Basic Output This is kind of like a histogram, except for the spacing This value of 75 corresponds to a class ranging from 67.5 to 82.5 (with a frequency of about 60)

A Few Options In this version proc gchart data=save.padgett; vbar plantht/space=0 type=percent levels=9; run; quit; Controls spacing between bars Changes the statistic from frequency to percent Sets the number of midpoints

So We Get… This is a histogram

Setting Midpoints You can also set midpoints explicitly: proc gchart data=save.padgett; vbar plantht/space=0 type=percent midpoints= ; run; quit; The chart will be constructed with these 7 values as class midpoints

Setting Midpoints We might try… proc format; value classes low-<30='<30' 30-<60=’30-60' 60-<90=’60-90' 90-<120=’90-120' 120-high='>120' ; run; proc gchart data=save.padgett; vbar plantht/space=0 type=percent; format plantht classes.; run; quit;

We Get… Oops SAS establishes the midpoints first then applies the format

The Discrete Option proc gchart data=save.padgett; vbar plantht/discrete space=0 type=percent; format plantht classes.; run; quit; Discrete establishes each distinct value of the midpoint variable as a midpoint on the graph. If the variable is formatted, the formatted values are used for the construction. If you use discrete with a numeric variable you should: 1. Be sure it has only a few distinct values. or 2. Use a format to make categories for it.

Result Bar width determines the space available for writing midpoint values

Bar Width proc gchart data=save.plantht; vbar plantht/discrete space=0 type=percent width=12; format plantht classes.; run; quit; Sets bar width

Horizontal Bar Charts proc format; value $pol_type 'CO' = 'Carbon Monoxide' 'LEAD' = 'Lead' 'O3' = 'Ozone' 'SO2' = 'Sulfur Diox.'; run; proc gchart data=save.projects; hbar pol_type/discrete type=percent; format pol_type pol_type.; run; quit;

Horizontal Bar Charts Besides the orientation of the bars, horizontal bar charts differ in that they produce a set of summary statistics by default. You can suppress this with the nostats option.

Summary Variables If I want my bar chart to summarize values of some analysis variable for each midpoint, use the sumvar= (and type= ) option. E.g.: proc gchart data=save.projects; hbar pol_type/discrete sumvar=jobtotal type=mean nostats; format pol_type $pol_type.; run; quit;

Result Note: Only two types of statistics are available with summary variables, the sum (which is the default) and the mean Mean total cost is now summarized for each pollution type.

Where to find more…

Axis Modification The two axes on the bar graph are referred to as the midpoint axis (maxis) and the response axis (raxis). Axes can be modified with axis statements. The general form of an axis statement is: axisn options; where n is an integer between 1 and 99.

Axis Modification Lots of options can be set in an axis statement. E.g.: proc gchart data=save.projects; hbar pol_type/discrete sumvar=jobtotal type=mean nostats maxis=axis1 raxis=axis2; format pol_type $pol_type.; axis1 label=(c=blue h=1.5 f=swissb ’Type of Pollution Project'); axis2 order=(0 to by 20000) minor=(n=1) value=(h=1.25 f=swissb) label=(f=swissb c=red h=1.5 'Mean Job Cost in Dollars'); run; quit; Assign axis statements to each chart axis Choose options/modifications for specified axis

The Result

Some Options c= sets axis color w= sets axis width label=(options) Sets axis label, some options: h= text height c= text color f= font style ‘Any Text’ is the axis label (overrides any label currently assigned) a= angle of the label text r= rotation of individual characters

Some Options value =(options) controls appearance of axis values, options are similar to those for label. order=(a to b by c) sets axis starting and ending points and increment minor=(options) major=(options)  Controls style of major or minor tick marks. Some options: n= number of ticks (for minor it’s the number between major ticks) h= height c= color w= width

Where to Find More (If you dare…)

Bar Fill Patterns In all charts to this point, all bars have been red. It is possible to change the color, and it is possible to give each bar a different color. To give bars different colors, specify patternid=midpoint in the hbar or vbar statement.

Bar Fill Patterns patternid=midpoint gives each bar its own “pattern” or color

Setting a Color List The goptions statement allows us to set several global graphics options, one of which is a color list: goptions colors=(blue red yellow cyan orange); proc gchart data=save.projects; hbar pol_type/discrete sumvar=jobtotal type=mean nostats maxis=axis1 raxis=axis2 patternid=midpoint; format pol_type $pol_type.; axis1 label=(c=blue h=1.5 f=swissb ’Type of Pollution Project'); axis2 order=(0 to by 20000) minor=(n=1) value=(h=1.25 f=swissb) label=(f=swissb c=red h=1.5 ’Mean Total Project Cost'); run; quit; This color becomes the default axis and text color

Setting a Color List Remember, setting a color is an option for any axis statement, so if you change the color list, you can always override the first color behavior in the axis statement. coutline= is an option you can use in the vbar or hbar statement to set the bar outline color.

Alternate Fill Patterns You can specify some alternate fill patterns for bars (particularly useful for creating black & white charts) with a pattern statement(s). The two major options in the pattern statement are c= and v=, for color and fill, respectively. Rules:  If no color is specified, the fill pattern is applied for each color in the color list.  If a color is specified, the fill pattern is applied only once.  The fill pattern can be set to on of Ln, Rn or Xn; where n is an integer between 1 and 5.

An Example L, R and X correspond to left-leaning, right-leaning and crossed lines. The number controls the thickness Add these pattern statements to your previous code to get the above bar graph: pattern c=black v=L1; pattern c=black v=R1; pattern c=black v=X1; pattern c=black v=L5; pattern c=black v=R5;

The group= option proc gchart data=save.padgett; hbar marsh/group=flower discrete sumvar=plantht type=mean nostats maxis=axis1 raxis=axis2 gaxis=axis3 patternid=midpoint; format marsh marsh. flower flower.; axis1 label=(c=blue h=1.5 f=swissb ’Marsh'); axis2 order=(0 to 120 by 20) minor=(n=1) value=(h=1.25 f=swissb) label=(f=swissb c=red h=1.5 'Mean Plant Height in Centimeters'); axis3 label=(c=green h=1.5 f=swissb ’Flowering'); run; quit; Sets up a “grouping” variable—bars for the full set of midpoints are constructed for each value of the group variable We can modify the group axis as well

Grouped Bar-Chart

The subgroup= option Subgroup creates stacked bars across levels of a variable. (Not appropriate for means)

The subgroup= option proc gchart data=save.padgett; hbar marsh/group=flower discrete type=percent nostats maxis=axis1 raxis= axis2 gaxis=axis3 patternid=subgroup subgroup=form legend=legend1; format marsh $marsh. flower $flower.; axis1 label=(c=blue h=1.5 f=swissb 'Marsh'); axis2 order=(0 to 50 by 10) minor=(n=1) value=(h=1.25 f=swissb) label=(f=swissb c=red h=1.5 ); axis3 label=(c=green h=1.5 f=swissb 'Flowering'); legend1 across=1 label=(c=blue 'Form of Plant') frame cshadow=gray position=(top right) mode=share;

Legend Modifications In a legend statement, some options available are:  label= similar to what is available in the axis statement.  across= and down= sets limit for row or column length in the legend (only use one)  frame draws a border around the legend  cshadow= places a shadow “behind” the legend in the specified color.

Legend Modifications  position=( ) places the legend, choices include: inside/outside left/right/center top/bottom/middle (default is bottom center outside).  mode= tells how to allocate space for the chart and legend, choices are: reserve: sets aside space for the legend before graph is drawn (can’t be used with position set to inside) share or protect: allows graph and legend to use the same space. Share has the graph drawn over the legend if they intersect, protect does the opposite.