📊

Introduction to Stata

Jul 16, 2024

Introduction to Stata

Overview

  • Speaker: Scott
  • Agenda: Introduction to Stata interface, uploading datasets, and basic commands and functionalities.

Opening Stata

  • When you open Stata, you'll see multiple windows:
    • Command Window: Where you enter commands
    • Review Window: Shows history of commands run
    • Variable Window: Displays variable names and labels
    • Properties Window: Displays properties of the selected variable

Uploading a Dataset

  • Stata provides example datasets for practice
    • Example: auto dataset
    • Can be uploaded via File Menu or the command sysuse auto

Windows in Stata

  • Command Window: Enter commands directly; past commands can be recalled and rerun.
  • Review Window: Keeps a history of all commands run, useful for recalling commands.
  • Variable Window: Displays variable names and their labels, which describe the variables.
  • Properties Window: Shows detailed properties of the selected variable (type, format, etc.).

Data Formats

  • Default file format: .dta (similar to .xls in Excel)
  • Stata can also import other formats like .xls, .csv, etc.

Tabs Overview

  • Data Tab: For data manipulation (sorting, editing, etc.)
  • Graphics Tab: To create various graphs (e.g., two-way graphs)
  • Statistics Tab: For statistical analysis (regressions, ANOVA, etc.)
  • Help Tab: Extremely useful for beginners; help command provides syntax and examples

Writing Commands

  • Commands can be written directly or generated by selecting options in the menus.
  • Some functionalities are only accessible via written commands.
  • Help Command: help followed by command name provides detailed information.
    • Example: help twoway for twoway graphs

Do File Editor

  • Do File: Script file to save commands; useful for running multiple commands at once
  • To run a Do File:
    • Write commands in the Do File Editor
    • Save and execute using Ctrl + D

Data Editor and Browser

  • Data Editor: Allows direct editing of the dataset (not recommended for extensive edits)
  • Data Browser: Allows viewing the dataset without the risk of accidental edits
    • Color codes: Numeric variables (black), strings (red), labeled integers (blue)

Variable Types

  • Numeric: Can be integers, long, double, etc.
  • String: Contain alphabets; no mathematical operations
  • Labeled Integers: Numeric values with assigned labels (e.g., 0 = Domestic, 1 = Foreign)
    • Using tabulate command to show tables
    • Example: tabulate foreign, nolabel shows raw values (0, 1) instead of labels

Conclusion

  • Overview of Stata's interface and basic functionalities
  • Importance of help command for learning
  • Usage of Do File Editor for script management

Thank you for watching!