Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 36 ยท Getting Started

What Is Stata?

Learn what Stata is, who uses it, how it compares with R, Python and SPSS, and how its data model of observations and variables shapes every command you type.

Stata is a statistical software package for managing data, running analyses and producing graphs. It was first released in 1985 by StataCorp and is now one of the standard tools in economics, epidemiology, public health, political science, sociology and many other research fields. Its main strengths are a very consistent command language, excellent regression and panel-data tools, and results that stay stable from one release to the next, so an analysis you wrote years ago usually still runs.

This course teaches Stata the way researchers really use it: you type commands (or save them in a do-file), look at the results, and keep the commands so anyone can repeat the work.

Honest note about this track. Stata is commercial software and cannot run inside a web page, so the examples here are not run on this site. Stata commands are shown in read-only code blocks, and we only describe output when it is certain. The interactive <TryIt> editors run small Python stand-ins, each labelled, that mimic the idea behind a command (for example, what generate or merge does to a table) so you can experiment. A stand-in is a teaching model, not Stata itself.

What you can do with Stata

What Stata does

Manage data Import, clean, merge, reshape
Describe Summaries, tables, graphs
Model Regression, panels, time series
Report Do-files, logs, exports

One tool covers the whole analysis

1 / 2

How Stata sees data

Stata holds one dataset in memory at a time. The dataset is a rectangular table:

  • Each row is an observation (a person, a firm, a country-year).
  • Each column is a variable (age, income, region).

Almost every command works on this table. Commands read variables, create new ones, or drop observations. When you type summarize income, Stata looks at the variable income in all observations currently in memory.

flowchart LR
    A["Raw data<br/>(CSV, Excel, .dta)"] --> B["Dataset in memory<br/>(observations x variables)"]
    B --> C["Commands<br/>(generate, regress, graph)"]
    C --> D["Results<br/>(output, graphs, tables)"]
    C --> B

Commands read the dataset and can change it; results flow out to the Results window, graphs and files.

Because there is only one dataset in memory, you must save your work or use another file to switch. That differs from R and Python, where you can hold many data frames at once. (Stata 16 and later can keep several datasets in frames, which we meet later.)

The next stand-in models the dataset idea in Python. It builds a tiny table and prints observation and variable counts, like the header of Stata's describe command.

Python Stand-in: a dataset is observations x variables

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stata versus other tools

Tool Style Typical strength
Stata Commands, one dataset in memory Econometrics, survey and panel data, reproducible do-files
R Functions and objects, many data frames Huge package ecosystem, statistics research
Python General language, pandas Machine learning, automation, web data
SPSS Menus first, syntax second Social-science teaching, point-and-click work
SAS Programs, long history Regulated industries such as pharma

None of them is "best". Stata is popular where the workflow is data cleaning, regression, publish a table, and where a colleague must be able to rerun your code in five years. If you already know R or Python you will pick up Stata quickly; if you know none of them, Stata is a gentle first choice because its commands read almost like short English sentences.

Anatomy of a Stata session

A typical analysis follows the same path every time:

  1. Start a log so the session is recorded.
  2. Load data with use or import.
  3. Inspect it with describe, summarize and list.
  4. Clean and create variables with generate, replace, recode.
  5. Analyze with regress, tabulate, graph.
  6. Save results and the data.

Here is a short, read-only example of the whole path. Do not worry about the details yet; every command gets its own lesson.

STATA
sysuse auto, clear              // load a dataset that ships with Stata
describe                        // what variables are there?
summarize price mpg             // quick numbers
generate price_k = price / 1000 // new variable
regress price mpg weight        // a regression

Comments start with // or sit between /* and */, or a line can begin with *. The dataset auto ships with every Stata installation: it holds 74 cars described by 12 variables, and it is used in the official documentation and in most tutorials, which makes it a great practice file.

Commands are verbs

Almost every Stata command is a verb followed by what it should act on:

STATA
summarize income
tabulate region
drop age

You can abbreviate commands: su is summarize, tab is tabulate, gen is generate. The manual shows the shortest allowed abbreviation by underlining it. In your own do-files, prefer a readable length such as summarize or gen, because other people must read your code.

Stata is also case-sensitive for names: Income and income are different variables, and commands are always lowercase.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In Stata's data model, what is an observation?

    Rows are observations (a person, firm or country-year); columns are variables.
  2. 2. How many datasets can classic Stata keep in memory at once?

    Stata holds one dataset in memory. Newer versions add frames to hold several, but the default is one.
  3. 3. Why does this site use Python stand-ins in the TryIt editors?

    Stata cannot run on the site, so labelled Python models teach the same ideas.
  4. 4. Which of these is the correct case for a Stata command?

    Stata commands are written in lowercase, and variable names are case-sensitive.

Summary

  • Stata is a command-driven statistics package for data management, analysis, graphs and reporting.
  • A dataset is a table: rows are observations, columns are variables, and one dataset lives in memory at a time.
  • Commands are short verbs that act on variables; many can be abbreviated, but readable code is better.
  • The auto dataset ships with Stata and is perfect for practice.
  • On this site, Stata code is read-only and the interactive editors run labelled Python stand-ins.

Next: Editions and Installation