Stata For Research

Why whole fields standardised on it, where it genuinely outperforms the alternatives, and the one habit that makes it worth using.

The short answer

Stata is a commercial statistics package that became the standard in economics, epidemiology, public health and parts of political science. That is not an accident of history: it handles panel and longitudinal data, complex survey designs and applied causal inference methods better and more conveniently than the general-purpose alternatives. If your field uses it, use it. If your data has a structure — repeated observations, clustering, survey weights — it is worth considering even if your field does not.

Where Stata genuinely outperforms

For a straightforward t-test or regression, any package will do. Stata earns its position where the data has structure that has to be modelled properly.

Panel and longitudinal data. The same units observed repeatedly over time. Stata was built around this: declaring data as panel data once tells the software the structure, and the models that follow — fixed effects, random effects, dynamic specifications — are available as first-class commands rather than as workarounds. In fields where panel data is the norm, this alone settles the choice.

Complex survey designs. Large national surveys use stratification, clustering and weights, and analysing them as though they were a simple random sample produces standard errors that are simply wrong. Stata handles this by declaring the design once, after which every subsequent command accounts for it. This is a common source of error in doctoral work using secondary survey data, and Stata makes it hard to get wrong.

Clustered and robust standard errors. Adjusting for the fact that observations within schools, clinics or firms are not independent. In Stata this is typically an option on the command rather than a separate procedure, which means it actually gets used.

Applied causal inference. Difference-in-differences, instrumental variables, regression discontinuity, propensity score methods and related approaches have mature, well-documented implementations, largely because the economists who developed and refined them work in Stata.

Survival analysis. Time-to-event data is well supported, which is part of why it is standard in epidemiology.

Do-files: the habit that matters

Stata can be driven by typing individual commands, and it should not be. Everything should live in a do-file — a script containing every step from reading the raw data to producing the final table.

The argument is the same one that applies to R scripts and SPSS syntax, and it is the most useful habit on this page. A do-file gives you a complete record of what was done, in order. It lets you correct an early error and re-run everything after it in seconds. It is the evidence behind your methodology chapter. And it means that when a result is questioned — by a supervisor, an examiner or a reviewer — you can re-run it and show exactly what produced it.

Practical structure worth adopting from the start:

  • One do-file that reads raw data and produces a cleaned analysis dataset, and separate ones for analysis. Never modify the raw file.
  • Comments explaining why, not what — why these cases were dropped, why this variable was recoded.
  • A log file capturing output, so results exist outside the session.
  • Version and date at the top, and dated copies kept as the analysis develops.

Stata also has a genuinely useful feature here: it can record your interactive session as a do-file, so exploratory work can be turned into a reproducible script rather than lost.

Practical points that cause trouble

  • Missing values behave in a specific way. Stata represents missing values as larger than any number, so a condition such as “greater than 40” will include missing values unless you exclude them explicitly. This silently corrupts subsetting, and it is the classic Stata error — worth checking every conditional statement you write.
  • One dataset at a time, traditionally. Stata is built around a single dataset in memory, which shapes how merging and reshaping work. Recent versions relax this, but the workflow assumption still runs through the documentation and most teaching.
  • Reshaping between wide and long formats is a distinct skill. Panel commands expect long format, most data arrives wide, and getting the reshape wrong produces a dataset that looks plausible and is not. Check the result rather than assuming.
  • Licence tiers differ in the amount of data they handle. If you are working with a large dataset, confirm your licence supports it before building the analysis around it.
  • User-written commands are a strength and a dependency. Much of the applied methods work circulates as community-contributed commands, often excellent and often the reference implementation. Record which ones you used and their versions, as you would an R package.

Stata, SPSS or R

Three considerations settle this for most doctoral candidates, roughly in this order.

What does your field use? This matters more than feature comparisons. Using the standard tool means your supervisor can help, your methods section reads as normal to reviewers, and the applied literature you are drawing on is written in the same vocabulary. In economics, epidemiology and public health, that is often Stata.

What does your data need? Panel structure, survey weights, clustering or applied causal inference methods point to Stata. Structural equation modelling, psychometrics and factor analysis point to R or dedicated SEM software. Straightforward group comparisons and regression can be done anywhere.

What can you actually access? Stata is commercial and licensed, and university licences end. Check yours runs past your intended submission date — losing access to your analysis environment during write-up is a real and avoidable problem.

As with any of these tools: no examiner has criticised a thesis for its software. They criticise analyses that did not suit the design, and results reported without the detail needed to evaluate them.

Questions researchers ask

Why do economists and epidemiologists use Stata?

Because it handles the data structures those fields work with better than general-purpose alternatives. Panel and longitudinal data, complex survey designs with stratification and weights, clustered standard errors and applied causal inference methods are all first-class features rather than add-ons. The methodological literature in those fields is also largely written with Stata implementations, so the tool matches the reading.

What is a do-file and why does it matter?

A script containing every step of your analysis, from reading raw data to producing final tables. It gives you a complete record of what was done, lets you correct an early error and re-run everything after it in seconds, and provides the evidence behind your methodology chapter. It is the single most useful habit in Stata, and Stata can convert an interactive session into one so exploratory work is not lost.

Why does my Stata condition include missing values?

Because Stata treats missing values as larger than any number, so a condition such as “greater than 40” includes them unless you exclude them explicitly. This is the classic Stata error: it silently corrupts subsetting, produces results that look entirely plausible, and gives no warning. Check every conditional statement you write for it.

Is Stata better than SPSS?

For data with structure — panel designs, complex surveys, clustering — yes, distinctly, and for applied causal inference methods it is generally the reference implementation. For straightforward group comparisons and regression they are comparable, and SPSS is easier to start with. The stronger consideration is usually what your field and supervisor use, since that determines how much help you can get.

Do I need to report which Stata commands I used?

Report the software with its version, and name any community-contributed commands you relied on along with their citations, exactly as you would an R package — much of the applied methods work in Stata circulates that way and the authors expect citation. Including your do-file as an appendix is straightforward and shows precisely what was run.

Related guides

Check the data structure is being modelled

Clustered or panel data analysed as though observations were independent produces standard errors that are simply wrong, and the output gives no sign of it. Describe your data and a PhD in your field will confirm the analysis fits.

Discuss your analysis