Stata is a statistics package popular in economics, political science, public health and other fields that rely on survey and panel data. You work with one dataset in memory at a time, using short commands such as describe, summarize, tabulate, generate and regress, typed in the command window or, better, saved in do-files so the whole analysis can be rerun. Its strengths include regression with robust or clustered standard errors, factor variable notation, margins for interpreting models and a large set of panel and survey tools. Learnr builds a Stata course matched to your field and statistics level, in short practical lessons.
How to learn Stata, step by step
- Work from do-files from day one. Open the do-file editor and put every command there, starting with a log file and loading the data. Rerunning the file from the top should rebuild all of your results, which is the habit that makes Stata work credible.
- Explore a built-in dataset. Load the auto dataset with sysuse auto and practice describe, codebook, summarize with the detail option and tabulate. Use help followed by any command name, since Stata help files are thorough and include examples.
- Clean and build variables. Create variables with generate, change them with replace and build group statistics with egen, such as a mean by region. Use if and in qualifiers carefully and remember that Stata treats missing numeric values as larger than any number.
- Combine and reshape data. Practice one-to-one and many-to-one merges, then check the _merge variable to see which rows matched. Reshape a dataset between wide and long formats, since panel commands expect long data with one row per unit and period.
- Run and interpret regressions. Fit a model with regress, add vce(robust) or clustered errors, and use i. notation for categorical variables and interactions. Then run margins to turn coefficients into predicted values and effects that are easy to explain.
- Learn panel tools and review regularly. Declare panel structure with xtset and compare fixed and random effects with xtreg. Daily Learnr lessons help keep commands and econometric ideas fresh while you work on assignments or research.
What you'll learn
- Write do-files and log files that reproduce an analysis from raw data
- Clean and create variables with generate, replace, egen and recode
- Combine datasets with merge and append and reshape between wide and long
- Run regressions with robust or clustered standard errors and factor variables
- Interpret models with margins and set up panel data with xtset
How long does it take to learn Stata?
Basic data cleaning and descriptive statistics take about 2 to 3 weeks at a few hours a week. Comfortable use of regression, panel methods and reproducible workflows usually takes 2 to 3 months, alongside the statistics or econometrics coursework those methods rely on.
What you need before you start
An introductory statistics course, especially regression, and access to a Stata license, which universities often provide. No programming experience is needed, though it makes loops and macros easier later.
Common mistakes to avoid
- Typing commands into the console without saving them, which leaves no record of how a cleaned dataset or result was produced.
- Writing a condition like if income > 50000 without excluding missing values, which Stata treats as larger than any number.
- Ignoring the _merge variable after a merge, so unmatched or duplicated rows silently change your sample.
How Learnr builds your course
Type your topic
Tell Learnr you want to learn Stata, or get as specific as you like.
Get a personalized course
Learnr instantly builds a full Stata course tailored to your goal and skill level.
Learn and level up
Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.
Stata questions, answered
Is Stata used outside academia?
Yes. Besides universities, it is used in government agencies, international organizations, consulting and health research, especially where survey, panel and econometric analysis are common.
Should I learn Stata, R or Python?
Learn the one your program, team or field uses. Stata is fast to learn for applied econometrics and has consistent syntax. R and Python are free and broader, so many analysts eventually use more than one.
Is Stata free?
No, Stata is commercial software sold by StataCorp in several editions, with student pricing available. Many universities provide licenses, so check with your institution before buying.
Explore more courses
More data and ai courses
- Learn SAS
- Learn Jupyter Notebooks
- Learn Kaggle
- Learn Feature Engineering
- Learn Recommender Systems
- Learn Hypothesis Testing
- Learn Power Query
- Learn DAX
Ready to learn Stata?
Start your free, personalized Stata course in seconds. It will be typed in and ready when you get there.
Start learning StataFree to start. No credit card.