Statistics Lab · step 01

Meet the cohort.

Start with the study design, one-row meaning, variable roles and a short set of checks that must pass before analysis.

Outcome: a labelled, checked dataset with its observational design and missing values made explicit.

Seven-step investigationNow: 01 · Meet the cohort

Analysis checkpoint

Check the study and file before calculating anything.

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

1 · Before you start

Have the common CSV and your chosen syntax file open. No statistical result is needed yet; this page establishes what each row and variable represents.

Words used on this page

Participant identifier
a code that should identify one person once.
Baseline
the starting point, before later outcomes are observed.
Missing value
information that was not recorded; it is not zero.
2 · Why this comes now

Every later table assumes that one row is one participant, medication review was recorded at baseline and the outcomes came afterwards. Checking that structure now prevents confident analysis of the wrong data.

3 · Do this now
  1. Import the common CSV and confirm that it contains 720 rows and 16 variables.
  2. Check that participant_id is unique, codes and ranges are plausible, and missing outcomes remain missing.
  3. Label the variables and save a readable audit trail in syntax and output.
Same step in Stata and SPSS

Run Section 01 in the Stata do-file or highlight and run Section 01 in the SPSS syntax file. Both routes should confirm the same row count, identifier check, value ranges and missingness.

4 · Read this

Read the dataset dimensions, unique-identifier check and missing-value summary. These are pass/fail checks, not evidence about medication review.

5 · Ready to continue when

You can explain one row, name the baseline exposure and later outcomes, and there are no unexplained duplicate identifiers, codes or ranges.

6 · Next step 02 · Characterise data Describe who entered the cohort before comparing medication-review groups.

The clinical frame

Know what one row means.

Each row is one synthetic participant aged 65–96. Baseline measurements include age, sex, living arrangement, deprivation, medication count, polypharmacy, frailty and disability. The exposure is a structured medication review. Outcomes are measured over six months.

Exposure

Medication review

med_review: 0 = no review; 1 = structured review.

Baseline risk

Frailty and disability

These help explain why some people were more likely to receive a review and to have poor outcomes.

Outcomes

Five measurement types

Continuous quality of life, binary disability, ordered frailty, falls count and time to admission.

Design

Observational cohort

The review was not randomised. Association is not automatically a treatment effect.

First checks

Import, label, audit.

Before a table or model, confirm that the file contains 720 rows, one unique identifier per row, expected ranges and visible missingness. The teaching file has 16 missing EQ-5D-style scores, 15 missing frailty categories, 10 missing falls counts and 8 missing disability outcomes.

Representative output · same teaching data in all three routes

Cohort audit

Study design                 observational cohort
Rows / participants          720
Variables                    16
Unique participant_id        yes
Eligible age range           65 to 96 years
Missing eq5d_6m              16
Missing disability_6m         8
Missing frailty_cat_6m       15
Missing falls_count_6m       10

What the output means

The file has one row for each of 720 eligible participants and no duplicate identifier. The four incomplete outcomes will produce different analysis denominators later. Passing this audit shows that the file matches the planned structure; it does not prove that every recorded value is clinically correct.

Write the interpretation like this

The analysis dataset contained 720 participants aged 65–96 years, with one record per participant. Outcome data were missing for 8 disability, 16 quality-of-life, 15 frailty-category and 10 falls observations.
Stata

Import the CSV, add value labels, then make the identifier and ranges fail loudly if they are wrong.

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

label define no_yes 0 "No" 1 "Yes"
label values med_review disability_6m no_yes

describe
isid participant_id
misstable summarize
assert inrange(age_years, 65, 96)
Download the complete commented Stata do-file
IBM SPSS Statistics

The supplied full syntax defines every field explicitly, then labels the codes and checks the unique identifier.

GET DATA
  /TYPE=TXT
  /FILE='gerostats_medication_review_cohort.csv'
  /ARRANGEMENT=DELIMITED
  /FIRSTCASE=2
  /DELIMITERS=","
  /VARIABLES=
    participant_id A7
    age_years F3.0
    /* Remaining variables are defined in the download */.

VALUE LABELS med_review disability_6m 0 "No" 1 "Yes".
DISPLAY DICTIONARY.
FREQUENCIES VARIABLES=participant_id age_years med_review.
Download the complete commented SPSS syntax file
R and RStudio

Read the CSV inside an RStudio Project, inspect its structure and use stopifnot() for checks that must pass.

cohort <- read.csv(
  "gerostats_medication_review_cohort.csv",
  na.strings = c("", "NA")
)

str(cohort)
dim(cohort)
stopifnot(!anyDuplicated(cohort$participant_id))
stopifnot(all(cohort$age_years >= 65 & cohort$age_years <= 96))
sort(colSums(is.na(cohort)), decreasing = TRUE)
Download the complete commented R script

Files

Keep the data and syntax together.

“Synthetic” is part of the metadata, not a small-print detail. Keep that label with any table, screenshot or teaching output made from these data.