Six people, two groups, and a visit log with repeat visits. Build an endpoint, compare risks, then audit three proposed pieces of code.
Inspect the source tables
Day 0 is enrollment. Follow-up is the number of days with complete capture of return visits. The visit log can include records outside the endpoint window.
cohort
id
arm
followup
1
A
30
2
A
30
3
A
12
4
B
30
5
B
30
6
B
30
visits
id
day
1
8
1
12
2
31
4
30
6
0
SQL workbench
Return six rows ordered by id, with columns id and event. Count a visit on days 1 through 30 inclusive. A person with no qualifying visit needs 30 days of follow-up to be classified as event-free. Otherwise the outcome is unknown.
Explain the group comparison
With 12 days observed, person 3 has an unknown outcome. Group A has one event among two observed people (50%). With 30 days and no visit, that person becomes an observed zero and group A falls to one in three. Group B stays at one in three. The change comes entirely from outcome ascertainment.
Code review desk
SELECT arm, AVG(event) AS risk
FROM outcomes JOIN visits USING (id)
GROUP BY arm;
Which issue or review action matters here?
Match the result to the question
First ask whether the code answers the stated question. Confirm the unit of analysis, eligibility, follow-up, outcome definition, numerator, denominator, and missing-data handling. A numerically plausible answer can still target the wrong population or quantity.
Run a small acceptance suite
Check expected counts before percentages. Independent hand calculations make a useful acceptance suite for this example.
Test invariants and structure. Reordering independent rows should not alter a simple summary. Adding a person with a missing outcome should increase enrolled and missing counts while leaving observed risk unchanged. Duplicate IDs should fail or be resolved by a documented rule. After joins, check row counts and key uniqueness.
Make and document the decision
Use this decision rubric before sharing an analysis. Ready means the question and row unit are clear, inputs are validated, expected cases pass, the workflow reruns from a clean session, outputs match the specification, and a reviewer can trace code to results. Needs revision means a fixable issue remains. Hold the result when the denominator, source data, cohort construction, or output cannot be explained. Record the issue, fix it, rerun the affected checks, and update the review note.
Review a real pull request
Read the README and change summary first. Run the stated command from a clean checkout. Compare generated tables with expected results. Inspect the diff for hard-coded paths, silent row drops, broad exception handling, unpinned dependencies, and accidental data files. Leave comments tied to specific behavior, then rerun after revisions.
Discussion
Questions, précisions et applications de cette ressource.