Thinking about Graphs The Grammar of Graphics and SAS.

Slides:



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

The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
With Microsoft ® Excel 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 GO! with Microsoft ® Excel 2010 Chapter 3 Analyzing Data with Pie.
Map Making Made Easy in ArcGIS
Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs
® Microsoft Office 2010 Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs.
Scatter Plots Section 1-5. Notes Tips for making good scatter plots Find the Independent and Dependent Variables Find the spread (Max-Min) for both sets.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
Excel Graphing Tutorial Lauren Ottaviano Fall 2012.
With Microsoft ® Excel 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Excel.
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
In Business Series © Prentice Hall Microsoft Office Excel 2007 In Business Core Chapter 5 Presenting Information with Charts.
CAHE Technology Help Desk ● (505) ● Week 8: Excel More than Rows and Columns.
Using Excel to Plot Farrokh Alemi, Ph.D.. Objectives Given a set of data plot a control chart using Excel software.
How To Make Graphs in Microsoft Excel Outline Making Bar Graphs Making Scatter Plots – 1 series Making Scatter Plots – Multiple Series.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Graphing in Excel Dr. Denise Harlem January 29, 2015.
MS-Word XP Lesson 8. Inserting Column to Table 1.Select column (click on top margin) 2.Click on table menu 3.Select insert sub menu and click on columns.
IMP 1- 11/9 (P), 11/10 (W) Warm Up- simplify each expression 1 ) 2 (x – 3) 2) 2x + 5x + 5y + 6y + 3 3) 2(x + 6) 4) 3x x – 10 5) 10 – 2(3 + 4)
Chapter 2 Presenting Data in Tables and Charts. 2.1 Tables and Charts for Categorical Data Mutual Funds –Variables? Measurement scales? Four Techniques.
Plotting II: By the end of this class you should be able to: Create a properly formatted engineering graph Create graphs of a function Place multiple plots.
Graphing. The Important Elements of a Graph  Horizontal Axis (X-Axis)  The Independent Variable. A change in this variable affects the y variable. 
Ranjeet Department of Physics & Astrophysics University of Delhi Working with Origin.
Lesson 2-3 Example Graph the ordered pairs C(2, 5) and D(0, 5). Then connect the points. What do you notice? Step 1 Graph point C. Start at the origin,
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.
Graphing Parameters Titles X-Axis Title Y-Axis Title Legend Scales Color Gridlines library(help="graphics") Basic Chart Types The R Graphics Package LineHistogram.
Introduction to SAS/Graph 9.2 Ken Barz Colorado Prevention Center 22Oct2009 Ken Barz Colorado Prevention Center.
Touchstone Automation’s DART ™ (Data Analysis and Reporting Tool)
Summer 2007 NSF MSPPaul Beaulieu / Barbara Perez Excel III Graphing Data.
Objective: How does a scientist set-up the appropriate graph?
Excel chapter 4.
Warm Up 1.What does the data to the right tell you? 2.Are there any trends that you notice about plant height?
Copyright © 2008 Pearson Prentice Hall. All rights reserved Committed to Shaping the Next Generation of IT Experts. Chapter 5 Charts and Graphs Robert.
Lecture 3 Topic - Descriptive Procedures Programs 3-4 LSB 4:1-4.4; 4:9:4:11; 8:1-8:5; 5:1-5.2.
Objective: To choose appropriate scales and intervals for graphs.
Intro to Excel - Session 4.11 Tutorial 4 - Session 4.1 Creating Charts.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Office Excel 2007 Lab 2 Charting Worksheet Data.
Graphing Basics. Creating a graph Draw the y-axis on the vertical axis and the X-axis on the horizontal one Label what variable is on each of the axis.
Thinking about Graphs The Grammar of Graphics and Stata.
Creating a Scatter Plot On a Mac. Data in Excel Spreadsheet Insert the variable you want on the x-axis in the left column Insert the variable you want.
DAY 4: EXCEL CHAPTERS 1 & 2 Rohit August 31 st,
Chapter 15: Spreadsheet and Worksheet Basics Lesson 96: Worksheets with Charts © 2010, 2006 South-Western, Cengage Learning.
Design tools: representing the functionality and appearance of solutions.
| resources for science teachers who like to think TopicDrawing graphsLevelKey Stage 3/GCSE (or.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Remember…  Please do not…  Change the background.  Change the icons.  Change the font. Use Times New Roman (size 12 font).  Use color. We cannot print.
Thinking about Graphs The Grammar of Graphics and Stata.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
SAS/GRAPH The Basics. Today’s Topics GOPTIONS GPLOT GCHART GCONTOUR G3D.
DAY 4,5,6: EXCEL CHAPTERS 1 & 2 Rohit January 27 th to February 1 st
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.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
Introduction to SAS ODS Graphics September 16, 2015 Rocio Lopez.
Microsoft Excel 2007 Noris Bt. Ismail Faculty of Information and Communication Technology Tel : (Ext 8408) BCOMP0101.
Microsoft Office XP Illustrated Introductory, Enhanced With Charts Working.
Click once to reveal the definition. Think of the answer. Then click to see if you were correct. Spreadsheet / Workbook A grid of rows and columns containing.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Using Excel graphing functions Mr. Lesser Do Now Compare the two graphs below. Fill out the similarities and differences chart on your paper. Then.
Excel Charts and Graphs
Using Excel to Construct Basic Tools for Understanding Variation
Excel Part 4 Working with Charts and Graphics
Tutorial 4: Enhancing a Workbook with Charts and Graphs
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.
Excel Part 4 Working with Charts and Graphics
Scatter Plots Section 1-5.
Graphing Notes.
How to Create Tables & Graphs in Excel
Excel Part 4 Working with Charts and Graphics
Presentation transcript:

Thinking about Graphs The Grammar of Graphics and SAS

Reconstructing a graph From proof-some-pollsters-are-putting-a-thumb- on-the-scale/

Questions toward reconstruction What are the graphical elements? How are they related to data? How are they arranged on the screen/paper? How are they decorated?

Graphical elements Points Line(s) Area

Relation to data Points: polling margins versus dates, essentially a scatter plot Lines: Grid lines, some emphasized Trailing margin is polling averages versus dates, connected (a.k.a. a line plot) Area: a fixed range around the trailing margin Given the points, the lines and area can be calculated

Arrangement Think in layers, points on top of lines on top of area

Layered together Notice the scales now match. The scales/coordinates are critical to how the elements are aligned on the page, and with each other.

Decoration/Aesthetics Titles and footnotes Color, weight, etc. of graphical elements Axis and legend text Grid or guidelines Etc. – there tend to be a large number of options at this point

Reconstructed

Programming The final program starts with the end result in mind Get the data, convert data types and layout (long vs. wide) as necessary Calculate data values needed Specify the graphics

Get, clean, convert the data data Iowapolls; infile "Z:\PUBLIC_web\Stataworkshops\Grammar of Graphics\Iowa Huffingtonpost.csv" firstobs=2 dsd dlm=","; input Pollster :$46. Dates :$16. Pop $ Ernst Braley Undecided Spread :$10; LV = (index(pop, "LV") gt 0); if LV; *Just use "likely voter" polls, not "registered voters"; polldate = input(trim(substr(dates, index(dates, "-")+2))||"/2014", mmddyy10.); format polldate mmddyy8.; margin = Ernst - Braley; run; proc sort; by polldate; run;

Calculate other needed data data Iowapolls2; set Iowapolls; retain w1 - w51 m1-m51; array w {51}; array m {51}; w{_n_} = polldate; m{_n_} = margin; do i = 1 to _n_; if w{i}+21 lt polldate then do; w{i}=.; m{i}=.; end; trailing21 = mean(of m1-m51); do i = 1 to 51; if w{i} ne. then lastdate = w{i}; end; format lastdate mmddyy8.; drop w1 -- i; run;

Calculate other needed data (cont.) data trailing; set Iowapolls2; keep trailing21 lastdate; by lastdate; if last.lastdate then output; run; data Polls; merge Iowapolls trailing(rename=(lastdate=polldate)); by polldate; trailing = lag(trailing21); lmoe = trailing - 3.5; umoe = trailing + 3.5; if polldate gt "01Sep2014"d; run;

Basic graphical specification proc sgplot; band x=polldate upper=umoe lower=lmoe; series x=polldate y=trailing; scatter x=polldate y=margin; run;

With decoration (setup) proc format; value margin -10 = "Braley +10" -5 = "Braley +5" 5 = "Ernst + 5" 10 = "Ernst + 10"; run; title "Iowa Senate Polls Coverged"; title2 "(But Badly Missed the Outcome)"; footnote "data from Huffington Post, analysis after fivethirtyeight.com";

With decoration (plot) proc sgplot; band x=polldate upper=umoe lower=lmoe / fillattrs=(color=gray) legendlabel="+3.5% / -3.5%"; series x=polldate y=trailing / lineattrs=(color=red) legendlabel="Trailing average"; scatter x=polldate y=margin / markerattrs=(symbol=circlefilled color=black) legendlabel="Polling margin"; refline 8.5 / lineattrs=(pattern=dot thickness=4 color=black) label="Actual Result: Ernst +8.5" labelloc=inside; xaxis grid; yaxis min=-10 max=10 grid label=" "; label polldate = "Poll Ending Date"; format margin margin.; run;

After all the steps