Software first contact

Stata: first contact

New to Stata? Find the data, saved instructions and output, then run one checked block with the shared cohort.

Use this optional on-ramp when the statistics desk is new. You will open the common cohort, run one saved block and be ready for Jennifer’s Analysis Step 01.

Your short software on-ramp

Learn just enough software to begin Jennifer’s analysis.

This is not a separate statistics course. It teaches only the Stata moves needed to open the shared cohort, run a saved instruction and recognise a correct result.

Before you start: no software knowledge is required. This page prepares the statistics desk; it does not teach the whole analysis. You need access to Stata and permission to save the teaching files in one folder. Read Jennifer’s fictional study background before beginning Step 01.

By the end you can

  • identify where data, saved instructions and output live;
  • open the 720-row teaching cohort without changing the source file;
  • run one reproducible frequency and age summary;
  • recognise the expected result and fix common first-run errors.

1 · Purpose

What Stata is for.

Stata is widely used for epidemiology, public health, clinical and health-services research. It combines data management, statistical models, survival analysis, graphics and epidemiological tables in one consistent command language.

The safe mental model is data + do-file → Results. Menus and the Command window can help you explore, but the saved do-file is the analysis record another researcher can inspect and rerun.

Data

One patient-shaped table

Rows are participants; columns are variables. A blank follow-up value is missing, not “no event”.

Instructions

One saved do-file

Commands run in order, with comments explaining each analytical decision.

Output

Results to interpret

Tables, estimates, intervals, warnings and graphs appear in Results; the do-file remains the reproducible source.

2 · Open or access it

Start with the supported route.

Stata is licensed software. First check your university or employer software portal: you may be offered a managed desktop install, remote desktop or institutional licence. Use the version and edition your organisation supports.

  1. Launch Stata. Stata/BE, SE and MP use the same commands in this exercise.
  2. Choose Window → Do-file Editor → New Do-file Editor. This is where the saved analysis lives.
  3. Put the CSV and supplied .do file in one folder. Choose File → Change Working Directory and select it.

A licence or activation error is an access problem, not a statistics problem. Use your institution’s supported route or Stata’s official installation guide in Go deeper.

3 · Find the statistics desk

Know where each part of the work lives.

Do-file Editor

Write, comment and save the reproducible sequence. Highlight a block and run it; do not rebuild the analysis from memory.

Results

Commands echo here with tables, estimates, notes and red error messages. Read the first error before changing code.

Variables

Shows names, labels and types currently in memory. It helps with spelling but does not replace the codebook.

Command and History

Command is useful for a quick check; History records what ran. Move any important command into the do-file.

Stata interface showing Results, Command, Variables and History
The statistics desk in Stata separates the current data, commands and printed results.
Stata do-file editor containing saved analysis commands
The do-file, not the scrolling Results window, is the analysis record.

4 · First reproducible run

Open the shared cohort and ask two simple questions.

Open the supplied do-file, or paste the block below into a new one. Run the complete block from the Do-file Editor. It checks the unique participant identifier, then asks: “How many people received medication review?” and “What is the cohort’s mean and age range?”

clear all
import delimited using "gerostats_medication_review_cohort.csv", ///
    varnames(1) clear

isid participant_id
count
tabulate med_review, missing
summarize age_years

Common cohort CSV

The same software-neutral, entirely synthetic data used in all three routes.

Download the CSV

Complete Stata do-file

Use its opening block now; later sections match the guided medical-statistics journey.

Download the .do file

5 · Successful output

Check the result before moving on.

Expected result

  • isid participant_id finishes without an error.
  • 720 observations in the cohort.
  • 517 (71.8%) with no medication review and 203 (28.2%) with a review.
  • Mean age 78.35 years, range 65–96.

Values 0 and 1 are codes, not yet reader-friendly labels. Step 01 keeps the raw field auditable and adds labels for interpretation. These summaries describe the cohort; they do not test whether review improved an outcome.

6 · First-run problems

Read the message; fix the cause.

r(601) file not found

Stata’s working directory does not contain the CSV. Run pwd, change folder, and keep the quoted filename exact.

no; data in memory would be lost

The current data have unsaved changes. For this synthetic exercise, rerun the supplied block from clear all; never do this with unsaved real work.

variable ... not found

Check that import succeeded and inspect describe. Stata names are case-sensitive and must match the CSV header.

The count is not 720

Stop. Re-download the common CSV and rerun the import from a clean session before calculating any statistic.

Terms you now need

Observation
one row representing one synthetic participant.
Variable
one measured field, such as age, review status or six-month disability.
Do-file
the saved, ordered record of Stata commands and comments.
Return code
the r(...) number attached to an error; use it to identify the cause.
Go deeper · medical-statistics and official Stata resources

Optional references for software detail, epidemiological methods and reproducible health-research reporting. You do not need these to begin Step 01.

Access · official Stata

Installation guide

Desktop download, edition selection and licence activation. Use institutional instructions first when access is managed.

Open Stata installation guidance
Learning · official Stata

Video tutorials

Short official demonstrations of the interface, data management, tables and regression workflow.

Open Stata videos
Epidemiology · official Stata manual

Tables for epidemiologists

Methods, formulas and examples for risks, odds, rate ratios and stratified epidemiological tables.

Open the epitab manual (PDF)
Medical statistics · BMJ

Statistics at Square One

Clinical examples covering displays, uncertainty, tests and study design; the free online text is an older edition.

Open the BMJ reference

On-ramp complete

Now meet the cohort properly.

You can open the shared data, run saved instructions and recognise a correct first result. Continue to Jennifer’s Analysis Step 01, where you will check the study design, timeline, variables and whether the file matches the fictional study.

Jennifer’s cohort · Analysis Step 01 Meet the cohort →