Statistics Lab · step 02

Characterise data.

Turn variable types, missing values and distributions into a concise description of the cohort.

Outcome: a defensible descriptive table and a clear view of the distributions before group comparisons.

Seven-step investigationNow: 02 · Characterise data

Analysis checkpoint

Describe the cohort before comparing groups.

Work through these six prompts in order. Each one supplies what the next one needs.

1 · Before you start

Step 01 must have passed: the participant identifier is unique, variable codes are understood and missing values have been counted.

Words used on this page

Categorical variable
a variable made of groups, such as yes/no or frailty category.
Continuous variable
a measured number that can take many values, such as age.
Distribution
the pattern of values, including centre, spread, skew and unusual observations.
Standard deviation
a measure of spread around the mean, usually shortened to SD.
Interquartile range
the middle 50% of values, usually shortened to IQR.
2 · Why this comes now

Description shows who the findings apply to and whether a mean, median, count or percentage represents each variable honestly. It also reveals problems that should be resolved before group comparisons.

3 · Do this now
  1. Count categories and calculate percentages using the correct non-missing denominator.
  2. For numeric variables, inspect the distribution before choosing mean and SD or median and IQR.
  3. Draft one overall cohort table and a short clinical description of the sample.
Same step in Stata and SPSS

Run Section 02 in Stata or SPSS. Stata uses tabulate and summarize; SPSS uses FREQUENCIES, DESCRIPTIVES and EXAMINE. Match the resulting summaries by variable type rather than by command name.

4 · Read this

Read the valid n and missing count first, then the percentage or measure of centre and spread. Use plots to notice skew, bounds and implausible values.

5 · Ready to continue when

Every important variable has a justified summary, missing denominators are visible and you can describe the cohort in clinical language without a p-value.

6 · Next step 03 · Compare groups Ask focused unadjusted questions about reviewed and unreviewed participants.

Measurement

Describe the variable you actually have.

Variable typeExampleUseful description
Nominal categorySex; medication reviewNumber, percentage and missing number.
Ordered categoryRobust → pre-frail → frailNumber and percentage in the meaningful order.
Continuous, roughly symmetricAgeMean, standard deviation, range and a plot.
Skewed or boundedMedication count; frailty indexMedian, interquartile range, range and a plot.
CountFallsFrequency distribution, median/IQR, mean and zeros.

There is no rule that every continuous variable must be reported with a mean and standard deviation. Match the summary to the distribution and to what readers need to understand.

Worked description

Build Table 1 before testing it.

The cohort has a mean age of 78.35 years (SD 6.73). Baseline frailty has a median of 0.213 (IQR 0.154–0.272). Medication count has a median of 4 (IQR 2–5). At six months, 158 participants are robust, 225 pre-frail and 322 frail; 15 values are missing.

Representative output · same teaching data in all three routes

Overall cohort description

Measure                         Result
Age, years                      78.35 (SD 6.73)
Baseline frailty index           0.213 (IQR 0.154–0.272)
Regular medicines                4 (IQR 2–5)

Six-month frailty category      n     % of 705 observed
Robust                          158        22.4
Pre-frail                       225        31.9
Frail                           322        45.7
Missing                          15          —

What the output means

Age is summarised with a mean and standard deviation because its distribution is sufficiently regular for that description. Frailty and medication count are described with medians and interquartile ranges because they are bounded or skewed. Percentages for six-month frailty use the 705 observed outcomes, while the missing number remains visible.

Write the interpretation like this

Participants had a mean age of 78.35 years (SD 6.73) and a median baseline frailty index of 0.213 (IQR 0.154–0.272). Among 705 participants with observed six-month frailty, 322 (45.7%) were classified as frail; 15 values were missing.
Stata

Use tabulate for categories and summarize, detail for continuous or skewed measures.

tabulate sex, missing
tabulate frailty_cat_6m, missing

summarize age_years baseline_frailty eq5d_6m
summarize medication_count falls_count_6m, detail

histogram eq5d_6m, normal percent
graph box eq5d_6m, over(med_review)
Download the complete commented Stata do-file
IBM SPSS Statistics

FREQUENCIES handles categories; DESCRIPTIVES and EXAMINE add means, quartiles and distribution plots.

FREQUENCIES VARIABLES=sex med_review frailty_cat_6m.

DESCRIPTIVES VARIABLES=age_years baseline_frailty eq5d_6m
  /STATISTICS=MEAN STDDEV MIN MAX.

EXAMINE VARIABLES=medication_count falls_count_6m eq5d_6m
  /PLOT=BOXPLOT HISTOGRAM NPPLOT
  /PERCENTILES(25,50,75)
  /STATISTICS=DESCRIPTIVES.
Download the complete commented SPSS syntax file
R and RStudio

Small base-R helpers make the requested summaries explicit and reproducible.

table(cohort$frailty_cat_f, useNA = "ifany")
prop.table(table(cohort$med_review_f))

summary(cohort[c(
  "age_years", "baseline_frailty",
  "eq5d_6m", "medication_count"
)])

sd(cohort$eq5d_6m, na.rm = TRUE)
IQR(cohort$medication_count, na.rm = TRUE)
hist(cohort$eq5d_6m, breaks = 20)
Download the complete commented R script

Further reading

Software references.

Stata data management

Official import, labels, codebook and data-checking features, with linked videos.

Open Stata guidance

IBM SPSS resources

Getting started with Data View, Variable View, descriptives and charts.

Open IBM resources

An Introduction to R

The official R manual on data, factors, summaries, tables and graphics.

Open the R manual