Stata 12 Merging Guide Nathan Favero Texas A&M University October 19, 2012.

Slides:



Advertisements
Similar presentations
Stata as a Data Entry Management Tool
Advertisements

Outlook Contacts Export Guideline Powered by DonorCommunity TM DonorCommunity eLearning Series v1.2, September 2012 Outlook Contacts Export Guideline Outlook.
Muhammad Qasim Rafique MS. EXCEL 2007.
Excel Tutorial 6 Managing Multiple Worksheets and Workbooks
Microsoft Excel 2010 ® ® Tutorial 6: Managing Multiple Worksheets and Workbooks.
Understanding Microsoft Excel
Logon then turn your monitor off! Creating a database A way of keeping information.
Visualizing Multiple Physician Office Locations Exercise 9 GIS in Planning and Public Health Wansoo Im, Ph.D.
Chapter 7 Data Management. Agenda Database concept Import data Input and edit data Sort data Function Filter data Create range name Calculate subtotal.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
1 Student Registration Import Must be imported into PBA by 2/18.
Getting Started with your data
Entering Data in Excel. Entering numbers, text, a date, or a time n 1Click the cell where you want to enter data. n 2Type the data and press ENTER or.
Spreadsheets. What are the parts Rows are numbered vertically Columns are lettered horizontally Where rows and columns intersect is called a cell A sheet.
Separating Columns in Excel. An extremely useful function in Excel is the Text to Column feature which can be used for any type of column separation but.
Lesson 4: Formatting the Worksheet
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Microsoft Word 2010 Lesson 10. Learning Objectives 1 Understand and Use Mail Merge 2 Select and Edit a main document 3 Create a source document 4 Preview,
Microsoft Word 2000: Mail Merge Basics Peggy Serfazo Marple Molly Calvello Support Professionals Business Applications - Desktop Microsoft Corporation.
Key Applications Module Lesson 16 — Excel Essentials Computer Literacy BASICS.
Importing your Own Data To display in GIS Lab 4a: (Table Join) Mapping By State, County, or Nation.
1 Lesson 22 Getting Started with Access Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
4/22/2017 5:36 PM EViews Training Creating Workfiles.
MS Word – Mail Merge Basic Steps Create Letter/Labels general information Create Excel File with variable Data Link Files through Mail Merge in Word Print.
IC 3 BASICS, Internet and Computing Core Certification Key Applications Lesson 10 Creating and Formatting an Excel Worksheet.
Key Data Management Tasks in Stata
Tricks in Stata Anke Huss Generating „automatic“ tables in a do-file.
Lesson 17 Getting Started with Access Essentials
Class Agenda Excel  PivotTables Excel & Word Integration Try PivotTable tutorial & work on Assignment #1.
Cell Alignment By default, text is left aligned and values are right aligned. You can also adjust vertical alignment.
10.11 Data Manipulation 1. Getting External Data.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 23 Getting Started with Access Essentials 1 Morrison / Wells / Ruffolo.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Lesson 10 - Mail Merge and Reviewing Documents Advanced Microsoft Word.
CCS – Mail Merge Mail Merge This presentation is incomplete without the associated discussion 1 Coloma Community Schools In-service 21 March 2014.
Lesson 1 – Microsoft Excel * The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Microsoft Excel 2003 Illustrated Complete Data with Other Programs Exchanging.
1 Lesson 13 Organizing and Enhancing Worksheets Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
COMP 116: Introduction to Scientific Programming Lecture 29: File I/O.
Spreadsheet Applications What is Excel?. Microsoft Excel MS Excel is an electronic workbook that gives you the ability to perform business and scientific.
Comparison of different output options from Stata
Case study : creating a usable MARC file from a spreadsheet Thomas Meehan Head of Current Cataloguing UCL Library Services CILIP CIG Metadata.
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
Function Of Microsoft Words Tables. Where Table section is located Table section is located on top row with File, Edit, View, Insert, Format, Tools, Window.
FIRST COURSE Integration Tutorial 2 Integrating Word, Excel, and Access.
Importing Data to Excel. Suppose you have a delimited* text file and you need to bring it into Excel. Follow these steps… *Delimited means text separated.
Understanding Microsoft Excel Lesson 1 – Microsoft Excel 2013.
Use SPSS for solving the problems Lecture#21. Opening SPSS The default window will have the data editor There are two sheets in the window: 1. Data view2.
1 PEER Session 02/04/15. 2  Multiple good data management software options exist – quantitative (e.g., SPSS), qualitative (e.g, atlas.ti), mixed (e.g.,
Understanding Microsoft Excel
Understanding Microsoft Excel
Understanding Microsoft Excel
Mail Merge for Lotus Notes and Excel User Guide
Microsoft Official Academic Course, Microsoft Access 2013
Mail Merge for Lotus Notes and Excel User Guide
Logan-Hocking Schools
Tutorial 6: Managing Multiple Worksheets and Workbooks
QS101 – Introduction to Quantitative Methods in Social Science Week 2: Introduction to Stata and Preparation of Field Work Florian Reiche Teaching Fellow.
Arrays and files BIS1523 – Lecture 15.
Spreadsheets.
ECONOMETRICS ii – spring 2018
Understanding Microsoft Excel
MODULE 7 Microsoft Access 2010
Creating and Modifying Queries
Introduction to Stata Spring 2017.
Stata Basic Course Lab 4.
Understanding Microsoft Excel
Key Applications Module Lesson 16 — Excel Essentials
Excel Tips & Tricks July 18, 2019.
Presentation transcript:

Stata 12 Merging Guide Nathan Favero Texas A&M University October 19, 2012

Contents Best Practices, pg. 3 Using Merge & Append, pg. 4 – Merge, pg. 11 – Append, pg. 14 Other Useful Commands, pg. 15 Importing Data into Stata, pg. 20 – Delimited Files: Importing Variable Names, pg. 20 – Importing from Microsoft Access, Pg. 21 Stata 12 Merging Guide

Best Practices Backup everything – Save a separate copy of the original files somewhere before you start modifying/merging Always use a do-file to make changes – This makes it much, much easier to come back later and fix mistakes or update data Never merge by school/district name (use IDs) Stata 12 Merging Guide

Merge or Append? MergeAppend Adding more variables Adding more observations (individuals and/or years) The same observations can be found in both files. The same variables can be found in both files Stata 12 Merging Guide

Merge Adding Variables Stata 12 Merging Guide

Append Adding Observations (Years) Stata 12 Merging Guide

Mixing Merge & Append You can only bind 1 direction (horizontally or vertically) at once. If you’re combining both directions, you have to plan the order in which you perform your steps so that you never have to bind in 2 directions at once. Stata 12 Merging Guide

Mixing Merge & Append For example, this won’t work. Stata 12 Merging Guide

Mixing Merge & Append This will work. Stata 12 Merging Guide

Mixing Merge & Append Or this will work. Stata 12 Merging Guide

Using Merge merge [n]:[n] [varlist] using [filename] merge 1:1 – Try using this if you’re unsure. – Merging two data files with the same unit of observation – Note: If using panel data, varlist must uniquely identify both individual and year merge m:m – Rarely used Stata 12 Merging Guide

Using Merge merge [n]:[n] [varlist] using [filename] merge m:1 or 1:m – Merging smaller unit of analysis (e.g., school) with larger unit of analysis (e.g., district) – Merging panel data (school-year) with cross-sectional (school) or time-series data (year) – m corresponds to the more specific data; 1 corresponds to the more general data (if you get this switched, you’ll simply get an error) – The [varlist] should uniquely identify the more general data (e.g, district, cross-section, or time-series) Stata 12 Merging Guide

Troubleshooting with Merge Does my variable list uniquely identify my observations? (Remember, you must specify both ID and Year variables in 1:1 for panel data.) Have I correctly specified 1:1, 1:m, or m:1? Should I be using append? Do I already have a variable named “_merge”? Are both files saved as “.dta”? Are the variable names exactly the same in both files? Are some of my variables strings in one file and numeric in the other? Stata 12 Merging Guide

Using Append append using [filename] append is a much simpler command than merge Just make sure that: – The variable names are exactly the same in both files. – The variable types (string or numeric) are the same in both files. – Both files are saved as Stata files (“.dta”) Stata 12 Merging Guide

Other Useful Commands destring [varlist], [replace or gen([var name])] ignore([characters to ignore]) – Convert a string variable to a numeric variable tab [var name] if regexm([var name], "[^0-9.]") – Show all of the values of a variable that are non- numeric Stata 12 Merging Guide

Other Useful Commands tostring [varlist], [replace or gen([var name])] [force] – Convert a numeric variable to a string variable gen [new var name] = string([numeric var name], "%12.0f") – Use this command instead of “tostring” if you have trouble with Stata giving you scientific notation Stata 12 Merging Guide

Other Useful Commands gen [new var name] = substr([string var name],[starting position],[number of characters]) – Create a new variable with a fixed number of characters from another string variable (e.g., first 3 characters) order [varlist], after([var name]) order [varlist], first – Change the order in which your variables appear Stata 12 Merging Guide

Other Useful Commands duplicates report [varlist] – Learn about the number of duplicates duplicates drop – Drop any exact duplicates duplicates tag [varlist], gen([var name]) – Create a variable that tags duplicate observations Stata 12 Merging Guide

Other Useful Commands foreach var of varlist [varlist] { rename `var' [prefix]_`var' } – Adds a prefix to the beginning of each variable name reshape wide [vars that contain varying data], i([identifying var(s)]) j([var that distinguishes observations that have the same identifying var(s)]) – Consolidates multiple observations into a single observation by adding variables Stata 12 Merging Guide

Importing Data into Stata: Delimited Files How to get Stata to read in the first row as variable names – Logic: At least one of the variables must be a completely numeric variable. 1.Open your file in Excel 2.Create a new column, and give it a variable name in the first cell. (You can put numbers in the column’s other cells, or just leave them blank.) 3.Save the file, and reload it into Stata. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2010 External Data  Text File (Export) Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2010 Select a file location and name. Click OK. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2010 Click Next. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2010 Select “Include Field Names on First Row.” Click Finish. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2010 Click Close. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2003 File  Export Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2003 Choose a location/name. Under “Save as type,” select “Text Files.” Click Export All Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2003 Click Next. Stata 12 Merging Guide

Importing Data into Stata: Microsoft Access 2003 Select “Include Field Names on First Row.” Click Finish. Stata 12 Merging Guide