Making Tables and Figures with Stata Biostatistics 212 Lecture 6.

Slides:



Advertisements
Similar presentations
Do files, log files, and workflow in Stata Biostatistics 212 Lecture 2.
Advertisements

Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin TECHNOLOGY PLUG-IN T2 BASIC SKILLS USING EXCEL.
Microsoft Excel Presented by ShoWorks Fair Software and Online Entries
Using Excel Biostatistics 212 Lecture 4. Housekeeping Questions about Lab 3? –replace vs. recode Final Project Dataset! –“Housekeeping” commands vs. data.
Microsoft Word Objectives: Word processing using Microsoft Word
Microsoft Excel 2010 Chapter 7
Integrating Access with the Web and with Other Programs.
1 CA201 Word Application Working with Charts Week # 7 By Tariq Ibn Aziz Dammam Community college.
Using Excel for Data Analysis in CHM 161 Monique Wilhelm.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 – Graphs and Charts: Delivering a Message.
1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 – Graphs and Charts: Delivering a Message Robert Grauer and Maryann Barber Exploring.
Introduction to Spreadsheets Presented by Frank H. Osborne, Ph. D. © 2005 Bio 2900 Computer Applications in Biology.
PAPER TITLE (TEMPLATE FOR A 841MM X 594MM POSTER PRESENTATION) The names of the authors The affiliation names go here Poster Basics Sections (ex: “1- INTRODUCTION”)
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 12 Spreadsheets and Business Graphics: Facts and Figures.
1 Good graphs & charts using Excel Module 1 Session 7.
1 Introduction to Spreadsheets Bent Thomsen. 2 What is an electronic spreadsheet? It is the electronic equivalent of an accounting worksheet, comprised.
McGraw-Hill/Irwin ©2009 The McGraw-Hill Companies, All Rights Reserved Business Driven Information Systems 2e Plug-In T2: Basic Skills Using Excel 2007.
With Alex Conger – President of Webmajik.com FrontPage 2002 Level I (Intro & Training) FrontPage 2002 Level I (Intro & Training)
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 1 1 Integrating Microsoft Office XP Tutorial 1 – Integrating Word and Excel.
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
Using Excel To help with data. Excel is a spreadsheet program that can interface with Word, or PowerPoint A spreadsheet program has cells (little blocks)
Making a figure, dates, and other advanced topics Biostatistics 212 Lecture 6.
Key Applications Module Lesson 19 — PowerPoint Essentials
Using Excel Biostatistics 212 Lecture 4. Housekeeping Questions about Lab 3? Final Project Dataset! –Check in.
Computers: Tools for an Information Age Chapter 12 Spreadsheets and Business Graphics: Facts and Figures.
Making a figure with Stata or Excel Biostatistics 212 Lecture 7.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. 3-1 Office Excel 2007 Lab 3 Managing and Analyzing a Workbook.
Making Tables and Figures with Stata Biostatistics 212 Lecture 6.
Exploring Excel 2003 Revised - Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 – Graphs and Charts: Delivering a.
Examples of different formulas and their uses....
LECTURE -9 CREATING A CHART IN MICROSOFT EXCEL. CHARTS Picture representation of data used Easy understanding Comparison of data Checking trends in data.
Computers Are Your Future © 2006 Prentice-Hall, Inc.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Organizing a project, making a table Biostatistics 212 Lecture 7.
Organizing a project, making a table Biostatistics 212 Session 5.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
Microsoft ® Office Excel 2007 Working with Charts.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin TECHNOLOGY PLUG-IN T2 BASIC SKILLS USING EXCEL.
Microsoft Office Illustrated Fundamentals Unit I: Working with Charts.
Organizing a project, making a table Biostatistics 212 Lecture 7.
Copyright 2002, Paradigm Publishing Inc. CHAPTER 18 BACKNEXTEND 18-1 LINKS TO OBJECTIVES Creating a Chart Sizing and Moving a Chart Sizing and Moving a.
Muhammad Qasim Rafique MS. EXCEL 2007 Introduction to Chart(s)
CREATING CHARTS By: Dr. Ennis - Cole OBJECTIVES b Identify the elements of an Excel chart b Identify the type of chart represents your data most effectively.
Using Google Sheets To help with data. Sheets is a spreadsheet program that can interface with Docs, or Slides A spreadsheet program has cells (little.
DAY 6: MICROSOFT EXCEL – CHAPTER 3 Sravanthi Lakkimsetty September 2, 2015.
Creating Graphs in PowerPoint Step 1 Open a new PowerPoint Document.
1. 2 Word Processing Word Processing is writing words and sentences on the computer. It is easy to change or move text in a word document. People use.
1. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Microsoft ® Office 2007 PowerPoint Lecture to Accompany.
PowerPoint: Charts Computer Information Technology Section 5-12 Some text and examples used with permission from: Note: We are.
Chapter 3 Graphs and Charts. Agenda Chart Object linking and embedding.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
Prepared by the Academic Faculty Members of IT. Tables Creating Tables. Merging Cells. Splitting Cells. Sorting Tables. Performing Calculations.
Graphing in Excel X-Y Scatter Plot SCI 110 CCC Skills Training.
An electronic document that stores various types of data.
ENGR 1181 College of Engineering Engineering Education Innovation Center Excel Graphing.
Excel Class Outline What is a spreadsheet? What can you do with them? The Cell - basic unit of a spreadsheet Making a Table - cells in Rows and Columns.
Formatting a Research Paper Lesson 10 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
XP New Perspectives on Creating Web Pages With Word Tutorial 1 1 Creating Web Pages With Word Tutorial 1.
Spreadsheet I n Concepts & operations. Concepts n Workbook: Excel file n Worksheet: sheet n Row: 1-???? n Column: A - Z, AA - ?? n Cell n Cell address.
Finalizing a Worksheet
Lesson 2 Tables and Charts
DEPARTMENT OF COMPUTER SCIENCE
MS-Office It is a Software Package It contains some programs like
Tutorial 3 – Creating a Multiple-Page Report
Chapter 5 Microsoft Excel Window
Charts A chart is a graphic or visual representation of data
Microsoft Office Illustrated Fundamentals
Presentation transcript:

Making Tables and Figures with Stata Biostatistics 212 Lecture 6

Housekeeping Brackets indicate optional parts of a command (usually!) use vs. insheet Low p-value for heterogeneity ≠ important interaction “The strata never lie” Final projects –Read 1-page directions closely

Today Organizing your Stata files Making a table Making a figure

Today Organizing your Stata files Making a table  Lab practice = Final Project Making a figure  Lab practice = Lab 6

Organizing your Stata files Pitfalls –Proliferating dataset –Can’t remember what you did –Can’t remember why you did it –Can’t easily redo with new data

Organizing your Stata files My system (it’s not perfect) 1)Import data into Stata a)Using a Stata command (e.g., insheet or import ) within a do file b)Using other method (e.g., StatTransfer?) outside a do file, then SAVE the “raw” Stata file immediately 2) Write a do file that “cleans” your data, and saves it as a new clean dataset 3) Write do files for each component of your analysis

Raw data My organizational scheme

Raw data Raw data.csv Pre-process My organizational scheme

Raw data Raw data.csv In Stata My organizational scheme Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.log My organizational scheme Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 1.log My organizational scheme Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 1.log Table 1.xls Cut and paste My organizational scheme Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 1.log Table 1.xls Cut and paste My organizational scheme Table 1.doc Cut and paste Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 2.do Table 1.log Table 2.log Table 1.xls Table 2.xls Cut and paste My organizational scheme Table 1.doc Table 2.doc Cut and paste Pre-process

Organizing your Stata files You will end up with: –1 or 2 Stata datasets Data, from Excel.dta (only if you import outside your do file) Data.dta –1 do file used for cleaning Data prep.do –1 do file to create each Table and Figure Table 1.do, Figure 1.do, Text data.do, etc –Matching log files (with the same names) for each do file Data prep.log, Table 1.log, Figure 2.log, Text data.log, etc

Organizing your Stata files Put them all in one folder called, “Stata files”, sort by file type. Example

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 2.do Table 1.log Table 2.log Table 1.xls Table 2.xls Cut and paste Any questions? Table 1.doc Table 2.doc Cut and paste Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 2.do Table 1.log Table 2.log Table 1.xls Table 2.xls Cut and paste My organizational scheme Table 1.doc Table 2.doc Cut and paste Lecture 3 Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 2.do Table 1.log Table 2.log Table 1.xls Table 2.xls Cut and paste My organizational scheme Table 1.doc Table 2.doc Cut and paste Lecture 3Lecture 5 Pre-process

Raw data Raw data.csv In Stata Clean data.dta Data prep.doData prep.logTable 1.do Table 2.do Table 1.log Table 2.log Table 1.xls Table 2.xls Cut and paste My organizational scheme Table 1.doc Table 2.doc Cut and paste Lecture 3Lecture 5 Lecture 7 Pre-process

Tables Two main purposes –Present the facts in a compact format –Provide side-by-side comparisons Six main components: –Data –Title, row heading, column headings –Row names –Footnotes Browner, W. Publishing and Presenting Clinical Research

5 Steps to Making a Table Step 1: Decide what the Table will be about –Sketch it out on paper Title, column headings, etc

5 Steps to Making a Table Step 2: Make the dummy table –Excel or Word –Makes you specify what you actually want! Row headings Decide on category cut-offs, labels Decide on reference categories for regression, etc Footnote liberally –Leave data cells blank

5 Steps to Making a Table Step 3: Write a do file that will produce each number you need –Iterative process, as you know

5 Steps to Making a Table Step 4: Copy and Paste the data in –Copy and Paste each number, or –“Copy Table” (under the “Edit” menu) –Minimize manual retyping, rounding –Use Excel to calculate and round for you

5 Steps to Making a Table Step 5: Format it so it looks nice –Standard, plain style – usually: Horizontal lines, not vertical Double-spaced Footnotes - *, †, ‡, §, ║, ¶ (or a,b,c,d,…) –Create a template for yourself

Word vs. Excel for Tables Stata  Word –Fewer steps, fewer files –But… Can’t cut and paste full tables Doesn’t do any calculations for you Formatting can become “corrupted”

Word vs. Excel for Tables Stata  Excel  Word –Can cut and paste values or whole tables –Set rounding, do calculations easily –Formatting easier? –Copy and Paste into Word (extra step)

Demo Table 1 for “Moderate drinking and coronary calcium in young adults: The CARDIA Study” –Basic content –Sketch –Generate numbers in Stata –Copy and paste into Word –Show final table –Demonstrate pasting a full table into Excel

Figures When use a figure? Making a figure with Excel Making a figure with Stata

When use a figure? When a graphical display of information more effectively conveys the intended message than words. “A picture is worth a thousand words”

Figures “A picture is worth a thousand words” How many words is this picture worth?

Figures “A picture is worth a thousand words” How many words is this picture worth? 48% of CARDIA participants consume alcohol moderately. Worth = 7 words

Figures “A picture is worth a thousand words” How many words is this picture worth?

Figures “A picture is worth a thousand words” How many words is this picture worth? WhiteBlack Drinks/dayn=1935n= %57% %26% %9% 2+8%8% Worth = 1 small table? (and avoid pie charts in general…)

Figures “A picture is worth a thousand words” How many words is this picture worth?

Figures “A picture is worth a thousand words” How many words is this picture worth? Proportion with CAC AbstainerMod drinker Black women White women Black men White men Can you see the interaction in this table without a figure? (Figures are good for illustrating interactions)

Figures “A picture is worth a thousand words” How many words is this picture worth?

Figures “A picture is worth a thousand words” How many words is this picture worth? Worth = 968 data points? Nice to show actual data points along with main effect, if possible!

Making a figure With Excel –First make a TABLE in Excel! Use Stata to generate numbers for the table –Create a figure from the Table using Excel tools With Stata –Use Stata commands to create the figure directly

Steps in making an Excel figure Sketch your figure Make a dummy TABLE Write a.do file to fill in the table Copy and paste from the log file or the results window into the Table Use the Chart Wizard to create the Figure Format, format, format until it looks nice

Example Figure 2 from Lipids paper

Steps in making an Excel figure Sketch your figure Make a dummy TABLE Write a.do file to fill in the table Copy and paste from the log file or the results window into the Table Use the Chart Wizard to create the Figure Format, format, format until it looks nice

Steps in making a Stata figure Sketch your figure Make a dummy TABLE Write a.do file with a graph command Copy and paste from the log file or the results window into the Table Use the Chart Wizard to create the Figure Format, format, format until it looks nice

Pay attention to… Formatting –Make it look nice and professional, but not gaudy Black and white, usually –The time-consuming part of making a figure is usually related to formatting.

Pay attention to… Labeling –Your figure should be understandable by itself, without the rest of the manuscript –All axes should be labeled. –Include important p-values

Pay attention to… The Figure Legend –Title, explanations, extra p-values, etc –Separate section in manuscript or at bottom of page – depends on journal

Stata vs. Excel for Figures Excel –Flexible and intuitive point-and-click figures Easy to create and modify Flexible, more options, error bars, adjusted estimates, good for bar graphs, etc –But… Requires an extra step – copy/pasting to Excel Harder to reproduce Much harder to do scatter plots

Stata vs. Excel for Figures Stata –Can create very customizable figures using 1 complex Stata command Easy to recreate – simple do file No error Scatter plots are MUCH easier with Stata –But… Harder to create the first time? - no point and click A little less flexible? Difficult to format: Graphic Editor helps address this

Stata vs. Excel for Figures Easiest tool Bar/Line* figuresExcel Confidence intervalsExcel Scatter plotsStata Box plotsStata Dot plotsStata * Where x-axis is categorical

Stata Demo Scatter plots: bmi vs. lipids –Iterative process of adding commands to do file –Cutting and pasting with substitution –Lowess smoother and linear fit lines –Post-graph editing

twoway (scatter dfev1 cumpy10 if menthol1==1, msymbol(plus) msize(small) mcolor(black)) /// (scatter dfev1 cumpy10 if menthol1==0, msymbol(circle_hollow)) /// (line m cumpy10 if menthol1==1, sort clcolor(black) clpat(dash) clwidth(thick)) /// (line nm cumpy10 if menthol1==0, sort clcolor(black) clpat(solid) clwidth(thick)) ///, ytitle(Change in FEV1 (milliliters), size(large)) yscale(titlegap(5)) /// xtitle(Pack-years of exposure to tobacco, size(large)) /// xscale(titlegap(3)) /// legend(order(1 "Menthol smokers" 2 "Non-menthol smokers" 3 "Menthol regression" /// 4 "Non-menthol regression")) /// scheme(s1mono) /// graphregion(fcolor(none) lcolor(none) ifcolor(none) ilcolor(none)) /// plotregion(fcolor(none) lcolor(none) ifcolor(none) ilcolor(none))

Key points It’s worth putting thought into your file organization Tables: –First sketch it on paper –Next make your dummy table –Only then write your do file Figures: –Make it with Stata if you can –Use dialog boxes to get the correct syntax, paste into your do file –Make bar charts with Excel Document everything you do!

Today’s Lab You will create 4 figures using stata. The focus will be on learning to use the dialog boxes to get the syntax right, and then transferring commands and options into a do file.