SHORT COURSE ON Stata SESSION ONE Getting Your Feet Wet with Stata



Similar documents
Directions for Frequency Tables, Histograms, and Frequency Bar Charts

ECONOMICS 351* -- Stata 10 Tutorial 2. Stata 10 Tutorial 2

Descriptive Statistics

Excel Charts & Graphs

Introduction to STATA 11 for Windows

SPSS The Basics. Jennifer Thach RHS Assessment Office March 3 rd, 2014

Data Analysis Stata (version 13)

SPSS: Getting Started. For Windows

WHO STEPS Surveillance Support Materials. STEPS Epi Info Training Guide

How to Use a Data Spreadsheet: Excel

4 Other useful features on the course web page. 5 Accessing SAS

Module 2 Basic Data Management, Graphs, and Log-Files

Introduction to Microsoft Access 2010

Introduction to PASW Statistics

Getting Started With SPSS

Introduction to Microsoft Access 2013

An Introduction to SPSS. Workshop Session conducted by: Dr. Cyndi Garvan Grace-Anne Jackman

Chapter 5. Microsoft Access

Appendix III: SPSS Preliminary

How To Use Spss

SPSS Manual for Introductory Applied Statistics: A Variable Approach

Q1. Where else, other than your home, do you use the internet? (Check all that apply). Library School Workplace Internet on a cell phone Other

Instructions for Importing (migrating) Data

Introduction to the use of the environment of Microsoft Visual Studio 2008

How to set the main menu of STATA to default factory settings standards

This book serves as a guide for those interested in using IBM

Working with Office Applications and ProjectWise

Using Ad-Hoc Reporting

Getting Started with Crystal Reports Session Description:

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

IBM SPSS Data Preparation 22

Affiliation Security

Query 4. Lesson Objectives 4. Review 5. Smart Query 5. Create a Smart Query 6. Create a Smart Query Definition from an Ad-hoc Query 9

Directions for using SPSS

What is a Mail Merge?

EpiData Analysis is a program for data analysis and data management.

Using SPSS, Chapter 2: Descriptive Statistics

Introduction to IBM SPSS Statistics

This book serves as a guide for those interested in using IBM SPSS

MICROSOFT OUTLOOK 2010 WORK WITH CONTACTS

Novell ZENworks Asset Management 7.5

Psy 210 Conference Poster on Sex Differences in Car Accidents 10 Marks

SPSS and AM statistical software example.

Section 6: Data Analysis Guide Overview

DiskPulse DISK CHANGE MONITOR

COURSE DESCRIPTION. Queries in Microsoft Access. This course is designed for users with a to create queries in Microsoft Access.

Adding A Student Course Survey Link For Fully Online Courses Into A Canvas Course

SPSS (Statistical Package for the Social Sciences)

Introduction to SPSS 16.0

User Guide for TASKE Desktop

How To Connect Legrand Crm To Myob Exo

Disaster Recovery Grant Reporting System (DRGR) Reports Module Draft User Guide

Hands-on Exercise Using DataFerrett American Community Survey Public Use Microdata Sample (PUMS)

Chapter 2: Clients, charts of accounts, and bank accounts

Access Queries (Office 2003)

Business Objects Version 5 : Introduction

Excel Database Management Microsoft Excel 2003

To create a histogram, you must organize the data in two columns on the worksheet. These columns must contain the following data:

Hands-on Exercise Using DataFerrett American Community Survey 5-Year Summary File: Foreign Born by Age by Sex

Trade Flows and Trade Policy Analysis. October 2013 Dhaka, Bangladesh

BID2WIN Workshop. Advanced Report Writing

Excel Using Pivot Tables

Market Pricing Override

MICROSOFT ACCESS STEP BY STEP GUIDE

Microsoft Access Basics

Sign in. Select Search Committee View

Avery Wizard: Using the wizard with Microsoft Word. This is a simple step-by-step guide showing how to use the Avery wizard in word

Click to edit Master text styles. FA Web Ad Hoc Query. Second level. Third level. Fourth level Fifth level. Training Material.

MetroBoston DataCommon Training

Business Objects 4.1 Quick User Guide

SPSS Step-by-Step Tutorial: Part 1

Importing and Exporting With SPSS for Windows 17 TUT 117

IBM SPSS Statistics 20 Part 1: Descriptive Statistics

CREATING EXCEL PIVOT TABLES AND PIVOT CHARTS FOR LIBRARY QUESTIONNAIRE RESULTS

Efficient, Quality-assured Data capture and analysis using EpiData

Data exploration with Microsoft Excel: univariate analysis

Customer Relations Management

MEDIAplus administration interface

Stata Tutorial. 1 Introduction. 1.1 Stata Windows and toolbar. Econometrics676, Spring2008

Excel for Data Cleaning and Management

RIFIS Ad Hoc Reports

You can send to all users or select groups of users by choosing one of the following options.

Introduction to ROOT and data analysis

Application & Quick-Start Guide

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

Using Big Datasets in Stata

Appendix 2.1 Tabular and Graphical Methods Using Excel

Microsoft Access 2010 Overview of Basics

User Training Guide Entrinsik, Inc.

This Quick Reference Sheet covers the most common technical issues that may be encountered.

Introduction to Microsoft Access 2003

Introduction to MS WINDOWS XP

Introduction to SPSS (version 16) for Windows

WebSphere Business Monitor V6.2 KPI history and prediction lab

Gateway Instructions Introduction to Warp 8 Personal Invoice Portal

Interaction with Operational Crystal Report... 3

Database Searching Tutorial/Exercises Jimmy Eng

You can preview your exam by clicking the View Questions button under the Review tab:

How to Use JCWHosting Reseller Cloud Storage Solution

Transcription:

SHORT COURSE ON Stata SESSION ONE Getting Your Feet Wet with Stata Instructor: Cathy Zimmer 962-0516, cathy_zimmer@unc.edu 1) INTRODUCTION a) Who am I? Who are you? b) Overview of Course i) Working with Stata Data Sets ii) Stata Syntax and Creating Stata Data Sets iii) Analyses and Graphics c) Tell me about any special requests. d) Bring flash drive to save files. e) Bold face will indicate a Stata command. f) For more information about Stata go to www.stata.com on the web. 2) EXPLORING Stata. a) Double click Stata icon to open the program. b) There are usually five windows to use adjust them with your mouse. Results window: results are displayed here. Review Window: past commands appear here -- click on command in the review window, and it will appear in the command window double click on command here and it will execute. Variables window: variable list appears here. Double click on variable and it will appear in the command window. Properties window: variable properties and dataset properties appear here. Command window: commands are typed here -- the general format is <command>, <option(s)> To execute a command, press enter. 1

c) Opening a Stata data file. i) Click File Open or click the open file button. Find the file I:\crzimmer\STATA\auto.dta ii) Double click on auto.dta this brings the data into another window, iii) you can see it by clicking on the Data Editor button or the Data Browser button. iv) OR type in the command window: use " I:\crzimmer\STATA\auto.dta", clear all v) Browser can look at specific observations or variables. br make mpg foreign br mpg-turn br in 15 br in 23/27 br if mpg==15 Press enter after each command. d) Go back to the beginning windows note that the commands you execute show in the Review window and the Results window. The variables appear in the Variables window. e) Checking the contents of your data. i) Type in the command window: describe ii) Describe can be limited to particular variables: d make price AND iii) Type in the command window: codebook iv) Press enter to get another observation on the screen OR Press Esc to get another screen of data, if needed OR set more off. v) Codebook can be limited to particular variables: codebook make price f) Changing storage type for efficiency. i) Type in the command window: compress ii) Note changes to storage types. g) Saving data so you can practice with it. i) Click File Save As or click diskette button. ii) Type in file name, keeping.dta. Choose location for file. Click Save. h) Saving output on so you have a record of your analyses. i) Open a log file by clicking on the log button. ii) Type in file name, replacing.smcl with.log. Choose location for file. Click Save. i) Viewing the log. i) Click on log button. ii) Click button next to View snapshot of log file, then click OK. j) Stata has wonderful help functions click on Help. k) To stop Stata at any time from running commands, click on the X button. 2

3) WORKING WITH DATA SAVED IN Stata a) Listing data. list price mpg foreign Press enter to get another observation on the screen OR Press Esc to get another screen of data, until more disappears OR set more off. b) Renaming variables. c) Labeling variables. d) Labeling values. rename make car_type label variable car_type Vehicle Type label define yesno 1 Yes 0 No label value foreign yesno ****Note: you can use the Variables Manager for these commands as well. Let s look at it. e) Reordering variables for viewing. order foreign mpg price Another example: order _all, alpha Check out other options for reordering as well. f) Sorting variables. i) For ascending sorts only. sort mpg Browse data to see sorting. ii) For ascending and descending sorts. gsort +foreign rep78, mfirst Browse data to see sorting. g) Producing frequency distributions the tabulate command. tab1 foreign To see the same frequency distribution with the numeric values instead of with value labels, type in the Command window: tab1 foreign, nolabel To produce frequency distributions for several variables, type in the Command Window: tab1 foreign mpg car_type To produce frequency distributions including missing data, type in the Command Window: tab1 rep78, missing 3

h) Producing histograms and bar charts. histogram mpg To save a graph, click on File, Save As, type in name for file, and save. Notice the.gph extension, which tells Stata that this is a graph file. i) Computing and Changing Variables. The generate and replace commands allow you to create new variables or change the values of existing variables. gen lengthsq=length*length gen price1000=price/1000 gen rep78r=rep78 replace rep78r=0 if rep78==. gen exp=0 replace exp=1 if price1000>=10 j) Dropping and Keeping Variables and Observations The commands drop and keep are used to drop and keep, respectively, both observations and variables. drop trunk drop in 7 drop in 23/27 drop if mpg==12 keep turn Browse the data to see dropping and keeping. k) Recoding. There are many ways to recode variables. Examples of how recodes can be done are listed here, but they are not applicable to the sample data. The x is a variable name and the numbers are its codes. recode x 1=2 recode x 1=2 3=4 recode x 1=2 2=1 recode x 1=2 2=1 * =3 (* means all other values) recode x 1/5=2 recode x 1 3 4 5=6 recode x 1 3/5=6 recode x 1 3/5=6 2 8=3 recode x 1 3/5=6 2 8=3 *=1 recode x min/5=min (or max) recode x.=9 recode x 9=. recode sex 0=2 recode relat 0=1 *=0 Try recoding rep78 into a new variable called rep78r where 1-3 equal 0 and 4-5 equal 1. Run a frequency distribution for rep78 and rep78r to make sure you did it correctly. 4

l) Working with part of a string variable. There are many string functions that allow you to work with parts of string variables. gen smake=substr(make, 1,3) m) Converting string variables to numeric ones and vice versa. i) Numeric to string. Type in the command window: decode foreign, gen (sforeign) OR Type in the command window: gen slength=string(length) ii) String to numeric. Type in the command window: OR Type in the command window: encode sforeign, gen (nforeign) destring slength, gen (nlength) EXERCISES: Using data from the 1991 General Social Survey, 1. Open the data set (I:\crzimmer\STATA\1991 u.s. general social survey.dta). 2. How many cases are there? How many variables? 3. Produce a frequency distribution for the happy variable for females only. How many cases are missing data? 4. Calculate a new variable that is the average of mother s and father s education. Call it avged. 5. Produce a histogram for the new variable. How many cases are missing data? 6. Run a frequency distribution for number of siblings. Then recode into a new variable called catsibs with FOUR categories: none, one, two, three or more. Check your recoding by running a frequency distribution and comparing it to the original one. January 2014. 5