You are on page 1of 35

Session 1

Module Introduction and


Getting Started with Stata

Introduction
Welcome
Housekeeping
Introductions
Name,

job, district, team

Module Overview
Module objectives are to provide you with
Skills in data analysis
Keeping in mind the analysis objectives
While learning the use of a specialised
statistical software package Stata
There will be a strong emphasis on conducting
meaningful analyses and on the interpretation
of the results.
3

Module content
Data

management
Data entry principles and practices
using

Epi Info
designing data capture screens,
labelling and entering data, etc.
Simple

statistical analysis

in

Epi Info
and using the statistics package, Instat.
Report

writing.
4

Duration and timetable


Morning

Afternoon

Day 1

Getting started with


Stata

Continued

Day 2

Tables

Project work part 1

Day 3

Graphs

Project work part 2

Day 4

Reviewing inference:
estimation and
confidence intervals

Reviewing inference:
Hypothesis testing

Day 5

Tests of association in 2Sampling weights


way tables

Day 6

Project work part 3:


writing the report

Putting it all in context


5

Module Learning Objectives


At the end of the module, participants will :

appreciate the power of Stata as a statistical package


be able to undertake elementary data management and
statistical analyses in Stata
have updated their practical knowledge of the key statistical
inference concepts of estimation and hypothesis testing
be able to produce graphs and tables using Stata,
have sufficient knowledge of Stata to be able to work
independently to produce other analyses

Prerequisites
Completion of Modules 1 and 2
At least a theoretical knowledge of statistical
inference

Resources
Stata

software - version 10

This

should be installed already


It may need updating and a Stata package
adding see later slides
Guide

to survey data analysis using Stata

Part

1 (Chapters 1 to 10) is used here


Part 2 (Chapters 11 to 20) is supplied for
reference
Inference
Used

guide

particularly in Sessions 7 and 8


8

Concepts more than software


The

emphasis is on the concepts of data


analysis and statistical inference

Using Stata

Rather

than just on Stata itself

Here we largely use the menus and dialogues


Though ways of using and reading commands are
introduced

Software

is now easy to master

It is the statistical concepts that benefit from a course


9

Learning objectives sessions


1 and 2
These

two sessions are about Stata


Participants will be able to:

Load and save data


Explore data

Calculate new variables

Using describe, codebook, summarize, etc


Using generate, recode, etc

Add labels to variables and to levels of a factor


Create subsets of data using drop and keep
10

Session Contents
In this session we look in particular at:
Windows and menus in Stata
Opening Stata data files
Stata dialogues
Typing and editing commands
Using Stata as a calculator
Exiting Stata
11

The four Stata windows

Review
Stata
Results
Variables
and
window for
typing
Stata
commands

12

The Stata menus and toolbar

The three most important menus


Data (for organising and managing the data),
Graphics (for visual exploration & presentation),
Statistics (for analysis).

Data, Graphics,
Statistics

13

Check Stata is up-to-date


Use

Help => Official updates


If updating is
needed, either:
Do it
automatically if
you are
connected to the
internet
Or use the files
on the CD/DVD
that are under
Stata resources14

The Data and Graphics Menus

15

Your turn

Click on several menus and explain their


usage to your neighbour

You can deduce the menu from the logic of the task
e.g. to draw a graph you go to the graphics menu!

Which menu would you probably need to use to:

save data?
sort a data set?
produce a bar chart?
tabulate the data?

Check

by finding the dialogue in Stata


16

Stata guide Section 1.2


You

use Stata as a calculator


Go through this section together
Check the buttons at the bottom of the
dialogue

They are the same on all dialogues

17

Using Stata as a calculator


To perform calculations, use

Data Other utilities Hand calculator


Type 2+3 into
the Expression
slot
Press the
Submit
button

See answer in Results Window, and


appearance of corresponding command in both
the Results and Review windows.

18

Results from the dialogue

You can get back to


any dialogue box by
typing db in front of
the command name.
e.g. db display

19

Creating an expression
Click create and
then complete
the resulting
expression
builder dialogue
box.
Or type:

display ln(10)
20

Stata guide Section 1.3

From this point you use a dataset that is supplied


Check that you have a working directory
And that it has the files for this module

Copy them in, if not


They are on the CD/DVD under Stata resources
You could install the Stata package as well if you wish.

Then use Files => Change working directory

To set this directory for the future

21

Opening a Stata data file

Use the menu sequence


File, Open
select (highlight) the file named
K_combined_short.dta
and click on Open

This will load the data from the Kenya socioeconomic survey into Stata

Look at the Variables Window. What do you


observe?
22

Options within the Data menu

23

An example of a dialogue box

Dialogue results
from using the
menu sequence
Data,
Describe data,
Describe data
contents
(codebook)
24

In the codebook dialogue box

The Submit button

The OK button does the same,

to its empty form.

? gives help on the command

without submitting the command to Stata.

The R button resets the dialogue box

but closes the dialogue box.

Cancel closes the dialogue box

instructs Stata to execute the command, leaving the


dialogue box visible.

associated with the dialogue box.

The word codebook at the top of the dialogue

shows codebook is the command that will be generated

25

Another dialogue box

Dialogue results
from using the
menu sequence
Data,
Describe data,
Summary
statistics

26

Results from codebook and summarize

27

Your turn
In Chapter 1 of the Stata guide, go through

Section 1.3
Section 1.4
Section 1.5

Ask a resource person if you are unclear about


any parts of the above sections.

28

Review

What do each of these buttons do?


Menus (and corresponding commands) used so far:
display
describe
codebook
list
generate
replace

What does each one do?

by/if//in
29

Your turn again


In Chapter 1 of the Stata guide, go through
Section

1.6
Section 1.7
Section 1.8
Ask a resource person if you are unclear about
any parts of the above sections.
30

Review again
Explain

(3<4) gives the value 1 in Stata


(3>4) gives the value 0

They

to a neighbour why:

then explain to you why the expression:

1 + (age>24) + (age>60)
Recodes a column into the values 1, 2 or 3

(Hint see Section 1.6 Fig 1.19 and 1.20 if you need
help)
31

Typing and editing commands


Professional

benefits by some use of Stata commands

These

In

are typed into the Command Window

To execute a command just press <Enter>.

To

use of Stata for data analysis

edit a previous command:

Click on it in the review window,


or use the Page-Up key perhaps repeatedly.

the Results Window


A dot appears in front of executed commands
whether generated by a dialogue, or by typing the
command.

32

Command for listing data


In the command window, typing
list region district household cluster
will show the contents of each of the variables region,
district, household and cluster.
(Note: Stata is case sensitive)
Pressing the GO button (see Stata menu bar) or the
space bar allows you to scroll down the page
To stop the display, press the red
break icon button
or press the letter q on your keyboard.
To exit Stata, use:

File Exit
33

Your turn yet again


In Chapter 2 of the Stata guide, go through

Sections 2.1 and 2.2


(You can go further if you have time)

If you have your own data


And it is not already in a Stata file, then:
In Chapter 3 of the Stata guide, go through

Sections 3.2.1, 3.2.2, 3.2.3


And discuss importing with the resource persons
34

and finally

Consider a data set from your own district or ministry


that is available as an Excel file.

Follow procedures similar to those in Section 3.2.3


of the Stata Guide, to load your Excel data set into
Stata.

Save your data as a Stata file, giving it an


appropriate name and noting the directory on your
computer where it has been saved.

Note: You will return to this data set in sessions that


follow.
35

You might also like