Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.

Slides:



Advertisements
Similar presentations
1 SESSION 5 Graphs for data analysis. 2 Objectives To be able to use STATA to produce exploratory and presentation graphs In particular Bar Charts Histograms.
Advertisements

Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Lecture Slides Elementary Statistics Eleventh Edition and the Triola.
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.
Graphing With Excel 2010 University of Michigan – Dearborn Science Learning Center Based on a presentation by James Golen Revised by Annette Sieg…
1 Computing for Todays Lecture 10 Yumei Huo Fall 2006.
Data Tutorial Tutorial on Types of Graphs Used for Data Analysis, Along with How to Enter Them in MS Excel Carryn Bellomo University of Nevada, Las Vegas.
Section 3.2 ~ Picturing Distributions of Data
SPSS Statistical Package for the Social Sciences is a statistical analysis and data management software package. SPSS can take data from almost any type.
XP New Perspectives on Microsoft Office Excel 2003 Tutorial 4 1 Microsoft Office Excel 2003 Tutorial 4 – Working With Charts and Graphics.
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.
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
SAS Lecture 5 – Some regression procedures Aidan McDermott, April 25, 2005.
Charts and Graphs V
Introduction to SAS/Graph Don Miller 812 Oswald Tower
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
C51BR Applications of Spreadsheets 1 Chapter 16 Getting Started Making Charts.
Computers: Tools for an Information Age Chapter 12 Spreadsheets and Business Graphics: Facts and Figures.
Quantitative Skills 1: Graphing
Introduction to SAS Essentials Mastering SAS for Data Analytics
Chapter 5: Charts Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
WINKS 7 Tutorial 2 Using WINKS SDA GRAPHS Permission granted for use for instruction and for personal use. © Alan C. Elliott,
Chapter 9 Creating and Designing Graphs. Creating a Graph A graph is a diagram of data that shows relationship among a set of numbers. Data can be represented.
Computers Are Your Future © 2006 Prentice-Hall, Inc.
The introduction to SPSS Ⅱ.Tables and Graphs for one variable ---Descriptive Statistics & Graphs.
Microsoft Office Illustrated Introductory, Premium Edition with Charts Working.
Copyright © 2008 SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Sullivan – Fundamentals of Statistics – 2 nd Edition – Chapter 2 Section 1 – Slide 1 of 27 Chapter 2 Section 1 Organizing Qualitative Data.
Creating Charts for the Agency Budget Creating Budget Charts, Slide 1Copyright © 2004, Jim Schwab, University of Texas at Austin.
A Picture Is Worth A Thousand Words. DAY 7: EXCEL CHAPTER 4 Tazin Afrin September 10,
Microsoft ® Office Excel 2007 Working with Charts.
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
Advanced Stata Workshop FHSS Research Support Center.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
ON PATHS LESS TRODDEN… Excursions in SAS/GRAPH ® and PROC TABULATE Presented by Aaron Rabushka © Aaron Rabushka 2000.
Statistical Graphics for the SAS System Computing for Research I 01/29/2014 Nathaniel L Baker.
Effective SAS greplay’ing and how to avoid stretching By David Mottershead Senior Programmer, Quanticate.
DAY 6: MICROSOFT EXCEL – CHAPTER 3 Sravanthi Lakkimsetty September 2, 2015.
Chapter 5 Working with Multiple Worksheets and Workbooks
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;
Excel Chapter 3: Excel Charts Objectives Decide which chart type to create Create a chart Change the chart type Change the data source and structure Apply.
MASUG September 15, Agenda  Guest Introductions  John Boling – SAS inSchool  Tim Garton – Health Forecasts  Announcements  Tips & Tricks 
Microsoft® Excel Use the Chart Tools Design tab. 1 Use the Chart Tools Layout and Format tabs. 2 Create chart sheets and chart objects. 3 Edit.
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
CHAPTER 7: PRINTING By: Miguel Sandria. INTRODUCTION AND PAGE SETUP  The spreadsheets may contain a great amount of information, therefore, we must remember.
MATH 2311 Section 1.5. Graphs and Describing Distributions Lets start with an example: Height measurements for a group of people were taken. The results.
SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
Statistical Fundamentals: Using Microsoft Excel for Univariate and Bivariate Analysis Alfred P. Rovai Charts Overview PowerPoint Prepared by Alfred P.
Microsoft Office XP Illustrated Introductory, Enhanced With Charts Working.
Behind the Scenes with SAS®: Using Customer Graphics in SAS® Output Louise Hadden Abt Associates Inc.
Organizing Qualitative Data
Chapter 8: ODS Graphics ODS graphics were not available prior to SAS 9.2 They have been implemented across a wide range of procedures Functionality isn’t.
INTRODUCTION TO SGPLOT Zahir Raihan OVERVIEW  ODS Graphics  SGPLOT overview  Plot Content  High value plot statements  High value plot options 
Computing for Research I 01/26/2011 N. Baker
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Organizing Qualitative Data
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Introduction to SAS Essentials Mastering SAS for Data Analytics
Presentation transcript:

Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1

Chapter 18: CREATING CUSTOM GRAPHS SAS ESSENTIALS -- Elliott & Woodward2

LEARNING OBJECTIVES SAS ESSENTIALS -- Elliott & Woodward3 To be able to use SAS® to create scatterplots and line graphs using GPLOT To be able to use SAS to create charts using PROC GCHART To be able to use SAS to create box plots (box-and- whiskers plots) using PROC BOXPLOT To be able to create basic plots using SGPLOT

18.1 CREATING SCATTERPLOTS AND LINE GRAPHS USING GPLOT SAS ESSENTIALS -- Elliott & Woodward4  PROC GPLOT is the basic routine used to obtain several types of graphs in SAS.  This section illustrates how to create scatterplots and line graphs using PROC GPLOT.  The abbreviated syntax for this procedure is as follows: PROC GPLOT ; PLOT plot-request(s)</ option(s)>;

GOPTIONS Before, Quit After SAS ESSENTIALS -- Elliott & Woodward5  It is a good idea to include the following command to reset all SAS graphics options before you use PROC GPLOT or other SAS graph procedures: GOPTIONS RESET=ALL;  Moreover, it is a good practice to include a QUIT statement after a plot to tell the SAS program that the graph is complete. QUIT;

The PLOT Statement SAS ESSENTIALS -- Elliott & Woodward6  The PLOT statement is the heart of the PROC GPLOT. Using this statement, you request an X- Y plot from the PROC GPLOT procedure using code such as the following: PROC GPLOT DATA=sasdatafile; PLOT yvariable*xvariable/options; RUN; The PLOT statement specifies the Y-axis (yvariable) and the X-Axis (xvariable)

SAS ESSENTIALS -- Elliott & Woodward7 Table 18.1 Common Options for PROC GPLOT OptionExplanation DATA = dataname Specifies which data set to use. ANNOTATE= Allows you to change default graphical elements or add new elements to the graph. (This feature is not demonstrated in this chapter.) UNIFORM Specifies that the same axes be used in all of the graphs produced by the procedure.

SAS ESSENTIALS -- Elliott & Woodward8 Table 18.2 Common Statements for PROC GPLOT Statement Explanation PLOT (and PLOT2) Specifies information about vertical and horizontal axes in a scatter/line plot, along with statement options that customize the look of the plot. These statements are discussed below. (PLOT2 is not discussed in this chapter) BUBBLE (and BUBBLE2) Similar to the PLOT statement, but specifies information that creates a bubble plot. (An example BUBBLE is given in the SGGRAPH section in this chapter.) AXIS, FOOTNOTE, PATTERN, TITLE These are statements that can be used to enhance graphs. Examples in this chapter illustrate these options. BY, FORMAT, LABEL, WHERE These statements are common to most procedures, and may be used here. Note: At least one PLOT or BUBBLE statement is required.

YVARIABLE and XVARIABLE SAS ESSENTIALS -- Elliott & Woodward9  yvariable defines the (left) vertical axis  xvariable defines the horizontal axis.  These can be either numeric or character variables. If you specify PLOT yvariable*xvariable=n;  n indicates which symbol to use for the plot points. (See Appendix A)  Request multiple plots by including more than one variable within parentheses, such as in PLOT (yvarl yvar2)*xvariable;  This statement produce two plots, one that is yvarl*xvariable and the other that is yvar2*xvariable.  You could specify the same series of plots using PLOT yvarl*xvariable yvar2*xvariable;

More about the PLOT statement SAS ESSENTIALS -- Elliott & Woodward10  Another form of the PLOT statement allows you to use a third variable that is a grouping (classification) variable. For example, PLOT yvariable*xvariable=group;  where group is some grouping variable. This will cause the points on the plot to be styled differently for each value of the grouping variable.  Options that appear after the PLOT specification are used to enhance the plot For example, PLOT yvariable*xvariable/CAXIS=color;  would cause the axes in the plot to be display in the specified color.

Creating a Simple Scatterplot SAS ESSENTIALS -- Elliott & Woodward11  Do Hands On Example p 395 (AGRAPH1.SAS) GOPTIONS RESET=ALL; Title "Simple Scatterplot"; PROC GPLOT DATA=MYSASLIB.CARS; PLOT HWYMPG*ENGINESIZE; RUN; QUIT; Requests a plot with HWMPG as the Y-Axis and ENGINESIZE as the X-AXIS

Resulting Scatterplot SAS ESSENTIALS -- Elliott & Woodward12

Make Modifications' SAS ESSENTIALS -- Elliott & Woodward13  Modify the PLOT the statement to make text RED: PLOT HWYMPG*ENGINESIZE/CTEXT=RED;

Managing Your SAS Graph – PLOT Statement (part 1) SAS ESSENTIALS -- Elliott & Woodward14 Table 18.3 Common Options for PROC GPLOT’s PLOT Statement (These options appear after a /) OptionExplanation CAXIS=color Specifies a color to use for the axis line and tick marks. (i.e. CAXIS=BLUE; ) See Appendix A. CFRAME= color Specifies frame color. CTEXT= color Specifies color for text. See Appendix A. HAXIS= or VAXIS= Specifies information about the horizontal or vertical axis. For example HAXIS=AXISk – Indicates which AXISk definition to apply to the horizontal axis. (i.e. HAXIS=AXIS1 ) VAXIS=AXISk - Indicates which AXISk definition to apply to the vertical axis. (i.e. VAXIS=AXIS2 )

Managing Your SAS Graph – PLOT Statement (part 1) SAS ESSENTIALS -- Elliott & Woodward15 Table 18.3 Common Options for PROC GPLOT’s PLOT Statement (These options appear after a /) (Part 2) OptionExplanation HREF=value list or VREF= value list Draws a horizontal or vertical line at the indicated axis value or values. LEGEND=legend Specifies which legend definition to use for a plot. An example is given in the chapter. NOLEGEND Suppresses the standard plot legend SYMBOL Specifies which symbol & attributes to use for points. See Appendix A. NOFRAME Suppresses the (default) frame around the plot GRID Draws grid line at major tick marks.

Using the Graph Your Create SAS ESSENTIALS -- Elliott & Woodward16  Copy Graph: Select Edit  Copy from the menu bar to copy the graph to the Clipboard (Then paste it into Word, Power Point, etc).  Export Graph: Right-click on the graph, select Save Picture as…, and select Files of Type to export the graph to a standard graphics format file. (PNG and BIT)  Print Graph: Use the File  Print menu option to print a hard copy of the graph. (or select Right-click, Print Picture …)

Enhancing a GPLOT Using the SYMBOL statement SAS ESSENTIALS -- Elliott & Woodward17  Often, the purpose of displaying a scatterplot is to illustrate an association between two variables.  The abbreviated syntax for the SYMBOL statement is as follows: SYMBOL ;  An example statement is SYMBOLl V=STAR I=RL C=BLUE L=2;

SAS ESSENTIALS -- Elliott & Woodward18 Table 18.4 Common Options for PROC GPLOT’s SYMBOL Statement OptionExplanation COLOR= color (or C=) Specify color for the symbol. For example, C=BLUE. See Appendix A for more colors. INTERPOLATION=type (or I=) Specifies an interpolation curve in the plot. Common options are: RL – Linear Regression RQ - Quadratic regression RC - Cubic regression STDk -Standard error bars of length k STDEV. STDM -Uses standard error of the mean JOIN -Joins dots BOXT – Specifies a high-low interpolation LINE=n(or L=) Indicates the pattern of the line drawn in the graph. For example, LINE=1 produces is a solid line. A value 2 value produces small dots, 3 is larger dots, and so on. See Appendix A for other options. VALUE=n (or V=) Indicates the symbol used on the plot. For example, V=STAR See Appendix A for other options.

Do Hands On Exercise p 399 (AGRAPH2.SAS) SAS ESSENTIALS -- Elliott & Woodward19 GOPTIONS RESET=ALL; Title ‘Simple Scatterplot’; PROC GPLOT DATA=MYSASLIB.CARS PLOT HWYMPG*CITYMPG; SYMBOLl V=STAR I=RL C=BLUB L=2; RUN; QUIT; Specify variables for plot Customize the symbol for the dots, and define an interpolation (I=RL. Linear Regression)

What the SYMBOL Statement Specifies SAS ESSENTIALS -- Elliott & Woodward20 SYMBOLl V=STAR I=RL C=BLUE L=2; The displayed symbol is a star (V=STAR). The displayed symbol is blue (C=BLUE). A linear regression line is displayed (I=RL). The displayed line is dotted (L=2).

Resulting Plot SAS ESSENTIALS -- Elliott & Woodward21

Customizing Axes in a Plot SAS ESSENTIALS -- Elliott & Woodward22  To change the characteristics of the plot axes, use the AXIS statement: AXIS ;  where n defines options for a specific axis such as AXISl, AXIS2, and so on. Applying an axis definition to a plot requires the following two steps: Step 1: Define the axis using an AXIS statement. Step 2: Associate the defined axis to a specific axis in the plot. GPLOT and GCHART

Using an AXIS Statement SAS ESSENTIALS -- Elliott & Woodward23  Axis options define the "look" of the axis: its scale, appearance, tick marks, and text. This is step 1 in using an axis: AXIS1 C=RED ORDER=(O TO 80 BY 5) LABEL=('City Miles Per Gallon' FONT=SWISS) OFFSET=(S) WIDTH=2 VALUE=(H=2);  Apply this axis to a plot (step 2 in using an axis): PROC GPLOT DATA=CARS; PLOT HWYMPG*CITYMPG/HAXIS=AXIS1; Apply AXIS1 to the plot like this.

SAS ESSENTIALS -- Elliott & Woodward24 Table 18.5 AXIS names for GPLOT and GCHART Axis Name for GPLOTRefers to which axis? HAXIS HAXIS=AXIS applies to the horizontal axis, also called the X axis in a standard X-Y plot. VAXISVAXIS=AXIS applies vertical axis, also called the Y axis in a standard X-Y plot.. Axis Name for GCHART Refers to MAXIS= MAXIS=AXIS applies to the midpoint axis, which is the axis associated with a group (categorical) specification. GAXIS= GAXIS=AXIS applies to the group axis, when you use a GROUP= statement (see example below). RAXIS= RAXIS=AXIS applies to the response axis, which is the axis associated with the count, percent, or frequency.

SAS ESSENTIALS -- Elliott & Woodward25 Table 18.6 Common Options for PROC GPLOT’s AXIS Statement (Part 1) OptionExplanation COLOR=color (or C=) Indicates the color used for the axis in the plot. For example, C=BLUE causes the axis to be blue. See Appendix A. LABEL=(specifications)Specifies characteristics of an axis label. The text arguments define specific parts of the label’s appearance. An example of a label statement is LABEL=(H=4 J=C C=BLUE "My Axis"); where H= 4 specifies Height of the text J=C means Justify Center C=BLUE specifies color of label text ORDER=(list) Specifies the order of the values on the axis. For example, ORDER=(1 to 100 by 5) specifies that the axis will contain the numbers 1 to 100 with axis label increments of 5. VALUE=(options) Specifies the height of text (among other items)—for example, VALUE=(H=4).

SAS ESSENTIALS -- Elliott & Woodward26 Table 18.6 Common Options for PROC GPLOT’s AXIS Statement (Part 2) OptionExplanation WIDTH=thickness Specifies width of the axis (affects the width of the entire frame unless a NOFRAME option is used as defined below). OFFSET=(x,y) Moves the axis away from the edge by a certain amount. For example OFFSET=(3,4) moves the x axis 3 percent horizontally, and the y axis 4 percent vertically. MAJOR=(options)Controls major tick marks. For example MAJOR=(COLOR=BLUE HEIGHT=3 WIDTH=2) MINOR=(options)Controls minor axis tick mark. MINOR=NONE causes no minor ticks to be displayed. For example MINOR=(NUMBER=4 COLOR=RED HEIGHT=1) JUSTIFICATION=type (J=)Justification, L=Left, C=Center, R=Right A=nSpecifies text angle. For example, use A=90 to place a horizontal axis at a 90 degree angle.

Note About Graphics in SAS SAS ESSENTIALS -- Elliott & Woodward27  For SAS version 9.3 and later, you may need to turn off automatic ODS graphics (which is the default in those versions) for some of the upcoming graph examples to work (particularly the colors). To turn off ODS graphics: ODS GRAPHICS OFF;  Turn graphics back on with ODS GRAPHICS ON;  Another way to return ODS graphics back to their normal default state in SAS versions 9.3 and later is ODS PREFERENCES;

Do Hands On Exercise p 402 SAS ESSENTIALS -- Elliott & Woodward28 AXIS1 C=RED ORDER=(0 TO 80 BY 5) LABEL=('City Miles Per Gallon' FONT=SWISS) OFFSET=(5) WIDTH=2 VALUE=(H=2); AXIS2 C=GREEN ORDER=(0 TO 80 BY 5) LABEL=(A=90 'Highway Miles Per Gallon' FONT=SWISS) OFFSET=(5) WIDTH=4 VALUE=(H=1); TITLE "Enhanced Scatterplot"; PROC GPLOT DATA="C:\SASDATA\CARS"; PLOT HWYMPG*CITYMPG/HAXIS=AXIS1 VAXIS=AXIS2 NOFRAME; SYMBOL1 V=DOT I=RL C=PURPLE L=2; RUN; QUIT;

Resulting Graph SAS ESSENTIALS -- Elliott & Woodward29

Make Some changes in the Code: SAS ESSENTIALS -- Elliott & Woodward30 AXIS1 ORDER=(0 TO 80 BY 5) LABEL=('City Miles Per Gallon' FONT=SWISS) OFFSET=(2) WIDTH=4 VALUE=(H=1); AXIS2 ORDER=(0 TO 80 BY 5) LABEL=(A=90 'Highway Miles Per Gallon' FONT=SWISS) OFFSET=(2) WIDTH=4 VALUE=(H=1); TITLE "Enhanced Scatterplot"; PROC GPLOT DATA=mysaslib.CARS; PLOT HWYMPG*CITYMPG/HAXIS=AXIS1 VAXIS=AXIS2 ; SYMBOL1 V=DOT I=RL C=GRAY L=5; RUN; QUIT;

Resulting Graph SAS ESSENTIALS -- Elliott & Woodward31

Displaying Error Bars in GPLOT SAS ESSENTIALS -- Elliott & Woodward32  To display data by groups with error bars on the graph to indicate the variability of data within a group, use the I= option in the SYMBOL statement. For example, SYMBOL INTERPOLATION=specification (or I= )  To employ this option to display error bars, use one of the following techniques: I=STD1JT produces error bars that are 1 standard deviation (STD1) and that are joined (J) at the means with tops (T) on each bar. STD also supports values of 2 and 3. I=BOXT includes box plots with tops (T) on each whisker.

Do Hands On Example p 403 (AGRAPH3.SAS) SAS ESSENTIALS -- Elliott & Woodward33 AXIS1 ORDER=(4 TO 12 BY 1) LABEL=('Number of Cylinders' FONT=SWISS HEIGHT=4)OFFSET=(5); AXIS2 ORDER=(0 TO 50 BY 5) LABEL=(A=90 'Highway Miles Per Gallon' FONT=SWISS HEIGHT=4) OFFSET=(5); PROC GPLOT DATA=mysaslib.cars; PLOT HWYMPG*CYLINDERS /HAXIS=AXIS1 VAXIS=AXIS2; SYMBOL1 I=STD1JT H=1 LINE=1 VALUE=NONE; RUN; QUIT; Note Axis numbers defined

Resulting Graph SAS ESSENTIALS -- Elliott & Woodward34 These bars are the result of the SYMBOL1 I=STD1JT… Statement.

Change Statement to SYMBOL1 I=BOXT etc… SAS ESSENTIALS -- Elliott & Woodward35 The I=BOXT option displays box plots.

18.2 CREATING BAR CHARTS AND PIE CHARTS SAS ESSENTIALS -- Elliott & Woodward36  Produce bar and pie charts with the SAS GCHART procedure. The abbreviated syntax is as follows: PROC GCHART ; HBAR | HBAR3D | VBAR | VBAR3D chartvar(s) ; PIE | PIE3D | DONUT | STAR chartvar(s) ;  Chart-type specifications such as HBAR and VBAR refer to horizontal and vertical bar charts, pie charts, and three-dimensional (3D) versions of the charts. An example is PROC GCHART DATA=MYDATA; HBAR STATUS/DISCRETE COUTLINE=BLUE WOUTLINE=3;

SAS ESSENTIALS -- Elliott & Woodward37 Table 18.7 Common Options for PROC GCHART OptionsExplanation DATA=dataname Specifies which data set to use. HBAR, HBAR3D, VBAR, VBAR3D, PIE, PIE3D, DONUT, or STAR Specify which type of plot to create. AXIS, FOOTNOTE, PATTERN, TITLE These are statements that can be used to enhance graphs. Examples in this chapter illustrate these options. BY, FORMAT, LABEL, WHERE These statements are common to most procedures, and may be used here.

SAS ESSENTIALS -- Elliott & Woodward38 Table 18.8 Common GCHART Options for Bar Charts (Options appear after /.) (Part 1) OptionExplanation CAXIS=color CFRAME=color CTEXT=color Specifies a color to use for the axis, frame or text. For example CAXIS=BLUE. COUTLINE=color WOUTLINE=n COUTLINE specifies color for bar outline (or SAME) and WOUTLINE specifies outline width. Default width is 1. For example COUTLINE=BLUE WOUTLINE=3 DISCRETE Treat numeric values as discrete (categorical) GROUP variable Split bars into groups using specified classification variable SUBGROUP variable Specify qualities of bars according to subgroups within the group defined by the GROUP variable (i.e. display a different color for each subgroup.) WIDTH=n SPACE=n WIDTH specifies BAR WIDTH and SPACE= specifies the space between bars.

SAS ESSENTIALS -- Elliott & Woodward39 Table 18.8 Common GCHART Options for Bar Charts (Options appear after /.) (Part 2) OptionExplanation INSIDE=statistic OUTSIDE=statistic Determines where a statistic will be displayed in a chart. Statistics are MEAN, SUM, PERCENT (PCT) or FREQ. TYPE=statistic Defines the statistic to be computed (to display on the chart.) Options include SUM, MEAN, PERCENT (PCT) and FREQ(default.) SUMVAR=varname Defines the response variable. When you used this option TYPE= should be MEAN or SUM NOLEGEND Suppresses Chart Legend CLM=p Specify the level for a confidence interval to be displayed on the bars. For example CLM=95. ERRORBAR=type Specify TOP, BARS, or BOTH.

Do Hands On Example p 406 (AGRAPH4.SAS) SAS ESSENTIALS -- Elliott & Woodward40 GOPTIONS RESET=ALL; Title "Horizontal Bar Chart"; PROC GCHART DATA=MYSASLIB.SOMEDATA HBAR STATUS /DISCRETE; RUN; QUIT; The /DISCRETE option tells SAS that the numeric values for the STATUS variable should be treated as discrete (individual) values.

Resulting Bar Chart SAS ESSENTIALS -- Elliott & Woodward41

Try Other Options, Observe Results SAS ESSENTIALS -- Elliott & Woodward42 Make this change and rerun. VBAR STATUS/DISCRETE WIDTH=10;  Make this change and rerun. HBAR STATUS/DISCRETE; PATTERN1 VALUE=R1 COLOR=GREEN;  Make this change and rerun. (Remove DISCRETE) HBAR STATUS;

18.3 DEFINING GRAPH PATTERNS SAS ESSENTIALS -- Elliott & Woodward43  The PATTERN statement allows you to change the color and pattern of a bar in a bar chart. A simplified syntax for the statement is PATTERN ;  For example, PATTERN1 VALUE=Rl COLOR=GREEN;  The in the statement determines which category the pattern will be defined for, where the categories are the order in which categories are displayed for the chart. For example: PATTERN1 VALUE=SOLID C=LIGHTBLUE;

Do Hands On Example p 408 (AGRAPH5.SAS) SAS ESSENTIALS -- Elliott & Woodward44 AXIS1 LABEL=NONE VALUE=(H=l.2); AXIS2 LABEL=(A=90 "Count"); TITLE "Vertical Bar Chart"; PROC GCHART DATA=MYSASLIB.SOMEDATA; VBAR GENDER/GROUP=GP MAXIS=AXIS1 RAXIS=AXIS2; PATTERN1 VALUE=Rl COLOR=GREEN; RUN; QUIT; Note that AXIS= controls the frequency (vertical) axis for GCHART and MAXIS= controls the appearance of the midpoint (horizontal) axis.

Resulting Bar Chart SAS ESSENTIALS -- Elliott & Woodward45

Make These Changes, Rerun SAS ESSENTIALS -- Elliott & Woodward46 VBAR GENDER/GROUP=GP SUBGROUP=GENDER; PATTERN1 VALUE=Rl COLOR=RED; PATTERN2 VALUE=R1 COLOR=BLUE; Assign a different pattern to each value in the group to display the groups like this.

Change the statement in PATTERN1 to VALUE=X4 SAS ESSENTIALS -- Elliott & Woodward47 The X4 option results in a crosshatch pattern.

Change VBAR to VBAR3D SAS ESSENTIALS -- Elliott & Woodward48

Continue to Chapter 18, Part 2 SAS ESSENTIALS -- Elliott & Woodward49

SAS ESSENTIALS -- Elliott & Woodward50 These slides are based on the book: Introduction to SAS Essentials Mastering SAS for Data Analytics, 2 nd Edition By Alan C, Elliott and Wayne A. Woodward Paperback: 512 pages Publisher: Wiley; 2 edition (August 3, 2015) Language: English ISBN-10: X ISBN-13: These slides are provided for you to use to teach SAS using this book. Feel free to modify them for your own needs. Please send comments about errors in the slides (or suggestions for improvements) to Thanks.