INTRODUCTION TO STATA - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

INTRODUCTION TO STATA

Description:

INTRODUCTION TO STATA V Tu n Khoa Tr n Th Trung Stata basics command-driven or menu-driven software modeling complex data from longitudinal studies or ... – PowerPoint PPT presentation

Number of Views:213
Avg rating:3.0/5.0
Slides: 21
Provided by: NguyenQu
Category:

less

Transcript and Presenter's Notes

Title: INTRODUCTION TO STATA


1
INTRODUCTION TO STATA
  • Võ Tu?n Khoa
  • Tr?n Th? Trung

2
Stata basics
  • command-driven or menu-driven software
  • modeling complex data from longitudinal studies
    or surveys ? deal for analyzing results from
    clinical trials or epidemiological studies
  • provides a powerful programming language

3
Stata interface in Window
4
Stata command
The basic language syntax for STATA commands is
by varlist command varlist exp if exp
in range weight
using filename , options
where the elements between brackets are optional.
5
Stata command
  • by varlist instructs Stata to repeat the
    command for each combination of values in the
    list of variables varlist.
  • command is the name of the command and can be
    abbreviated for example, the command display can
    be abbreviated as dis.
  • varlist is the list of variables to which the
    command applies.
  • exp is an expression.
  • if exp restricts the command to that subset of
    the observations that satis?es the logical
    expression exp.
  • in range restricts the command to those
    observations whose indices lie in a particular
    range.
  • weight allows weights to be associated with
    observations
  • using ?lename speci?es the ?lename to be used.
  • options are speci?c to the command and may be
    abbreviated.

6
Stata command
  • Example 1
  • Stata Command
  • .bysort black summarize age if year gt 80,
    detail
  • Results
  • Summarizes age separately for different values of
    black, including only observations for which year
    gt 80, includes extra detail.

7
Stata command
  • Example 2
  • Stata Commands
  • .generate agelt30 age
  • .replace agelt30 1 if age lt 30
  • .replace agelt30 0 if age gt 30 age lt.
  • Result variable agelt30 set equal to 1, 0, or
    missing
  • Generally exp used with commands generate and
    replace

8
Stata command
  • Click Help / Stata command
  • Type key word (Ex summarize)
  • See details

9
Do Files and Log Files
  • A do file is a text file with STATA code that
    STATA runs line by line, as if the sentences
    where written in the STATA command window.
  • A log file is a text file with all the results
    that appear in the STATA results window.
  • the user selects when to start and when to stop
    logging to the log file

10
Variable name
  • Have up to 32 characters but shorter names are
    easy to type
  • Stata names are case sensitive (age?Age)
  • Should
  • short lowercase
  • single word
  • underscore to separate word
  • effort
  • fpe
  • family_planning_effort
  • familyplanningeffort

11
Variable type
  • Nummeric variable
  • String variable
  • Missing value
  • numberic dot (.)
  • string

12
Some Basic Commands
  • computing basic statistics
  • summarize ypc
  • summarize ypcf wpopwt
  • summarize ylab wpopwt if age gt25 and age
    lt55
  • generate new variables
  • generate ypc2 ypc2
  • tabulate data
  • table skill wpopwt, c(mean ylab)

13
Some Basic Commands
  • renaming variables
  • rename ypc2 ypcf22
  • eliminating variables
  • drop ypc22
  • replacing values
  • replace male0 if male1

14
Open data from Excel format
  • Import data from excel file

15
Open data from Excel format
16
Open data from Excel format
17
Review data
18
Starting descriptive analysis
19
Starting descriptive analysis
20
Output Window
Write a Comment
User Comments (0)
About PowerShow.com