Why Subject Identity Needs an Explicit Rule
A subject identifier is the link that allows records from a study to be understood as belonging to the same participant. If that link changes between files, or if one identifier is accidentally assigned to two participants, later data preparation can combine different people or split one person into apparently separate subjects. Either error can affect data summaries and model inputs.
The identifier therefore needs a clear scope and a stable meaning. In this tutorial, a subject means the study participant as defined by the study’s data specification. An identifier is a label for that participant, not a measurement. The identifier may recur on many records for the same subject; subject-level uniqueness does not mean that the identifier must occur only once in a dataset.
The earlier material on Defining the Pharmacometric Record Grain establishes what one row represents. That distinction matters here: a subject identifier identifies the subject associated with a row, whereas a record-level identifier would distinguish individual rows. Repeated subject identifiers across multiple rows are usually expected. Do not test for subject-ID uniqueness across all observation rows as if every row had to represent a different participant.
Choose the Scope and Preserve the Identifier
Before checking data, specify the identifier’s scope. A study may assign IDs that are unique only within a site, within a study part, or within a particular source system. An ID such as “014” is not necessarily globally unique simply because it looks distinctive in one file. If different sites can issue the same local value, the site or another documented namespace is needed to interpret it.
A practical design uses a canonical study subject ID for analysis and retains the source identifiers and their provenance in a controlled mapping. The canonical value should be stable, distinct for each study subject, and assigned using a documented rule. It should not depend on row order or on the order in which files happen to be processed: sorting or adding a file could otherwise change assignments. Keep the raw source value as received so that transformations and reconciliations can be reviewed.
Identifiers are labels, even when they contain only digits. Converting “0007” to the number 7 discards information and may make it impossible to compare the value with source records. Likewise, changing case, removing punctuation, or trimming spaces can merge two distinct IDs if the source system treats those characters as meaningful. Apply only transformations authorized by the data specification, and record them. A blank string, a whitespace-only string, or a documented placeholder such as “UNKNOWN” may represent missingness; decide this by an explicit rule rather than by visual inspection alone.
Completeness and Uniqueness Checks
For a subject roster intended to contain one row per subject, let \(R\) be the set of roster rows and let \(I\) be the set of their interpreted subject identifiers. A complete, unique roster has one nonmissing identifier per row and a different identifier for every subject. Equivalently, if every row is expected to describe a distinct subject, then \(|I|=|R|\), provided no row has a missing identifier. This is a useful check, not proof that the identifiers refer to the correct people: a wrongly assigned but unique value can still pass.
For a file with repeated records per subject, the test is different. First check that every row that requires a subject association has a nonmissing subject identifier. Then compare the observed subject IDs with the authoritative roster or crosswalk. Repeated IDs across rows are allowed. A duplicate-ID test is meaningful only when the rows being tested are supposed to be one-per-subject, or when the test is scoped to a mapping table that should have one row per source identifier.
Missingness also requires a stated denominator. A rate calculated over data rows answers “what fraction of rows lacks a subject ID?” A rate over a subject roster answers “what fraction of expected subjects lacks an ID?” These are different questions. Report which one is being calculated, and distinguish genuinely missing values from values that merely look unusual.
Worked Example: Detecting Reused Site-Local IDs
Suppose a hypothetical study receives a roster from two sites. Each site assigns its own local subject numbers, so the raw values are not guaranteed to be unique across sites.
| Site | Raw subject ID |
|---|---|
| North | 001 |
| North | 002 |
| South | 001 |
| South | 003 |
There are four roster rows and four participants. If raw IDs alone are treated as the identifier, the set is \(\{001,002,003\}\), which contains only three distinct values. Thus \(4-3=1\) row cannot be distinguished by raw ID alone: “001” occurs at both sites. The raw ID fails a study-wide uniqueness check.
If the data specification confirms that local IDs are unique within site, the scoped identifiers are the pairs (North, 001), (North, 002), (South, 001), and (South, 003). These are four distinct pairs, so the site-and-ID combination distinguishes the four roster entries. A canonical ID can then be assigned to each verified subject, for example SUBJ-0001 through SUBJ-0004. The assignment must be maintained in a crosswalk; it must not be regenerated from file row order.
This check establishes that the scoped values are distinct in this roster. It does not independently establish that the two site records labelled “001” belong to different people; that conclusion depends on the study’s assignment rules and source documentation.
Worked Example: Quantifying Missing Subject IDs
A hypothetical source file contains 120 data rows. Inspection using a documented rule finds three blank subject-ID cells and two cells containing the agreed missing placeholder “UNKNOWN.” All other cells contain non-placeholder values.
The number of rows missing a usable subject ID is \(3+2=5\). Because the denominator is all 120 source rows, the row-level missingness rate is
Thus 5 of 120 rows, or about 4.17%, cannot be linked to a subject using this field. This is a row-level rate, not a claim that 4.17% of the study participants lack IDs: a participant can contribute multiple rows. The next action is to report and investigate the affected source rows, not to invent IDs based on row position.
Suppose another value is “0007.” It is not missing under the stated rule, and it must remain a character label so its leading zeros are preserved. If the specification has not established whether “unknown,” “UNKNOWN,” and a blank are equivalent, the missingness count is not yet well-defined; the coding rule must be resolved first.
Reconcile IDs Across Files
A repeated identifier in two files does not automatically indicate an error. If both files contain records for the same participant, the repetition is expected. The question is whether each source value has the same meaning in each file and whether the relationship to the canonical study subject is consistent. A useful crosswalk records the source system or file context, the raw ID, the canonical subject ID, and the evidence or rule supporting the mapping.
For a given source namespace, one source ID should not map to two canonical subjects. Conversely, the same canonical subject may have different IDs in different systems, such as a laboratory system and an enrollment system. That is not a collision if the mappings have been verified. Do not infer identity from similar demographics alone; use the approved linkage evidence and refer unresolved discrepancies to the responsible data owner.
Worked Example: Finding an Inconsistent Cross-File Mapping
Two hypothetical files are reconciled against an enrollment crosswalk. The crosswalk is intended to map each source-and-ID combination to one canonical subject.
| Source | Raw ID | Canonical subject ID in crosswalk |
|---|---|---|
| Clinic | C101 | SUBJ-001 |
| Clinic | C102 | SUBJ-002 |
| Clinic | C103 | SUBJ-003 |
| Laboratory | L501 | SUBJ-001 |
| Laboratory | L502 | SUBJ-002 |
| Laboratory | L503 | SUBJ-009 |
The two sources use different raw IDs for subjects SUBJ-001 and SUBJ-002. Those are valid cross-file correspondences if supported by the enrollment records. The row for L503 needs review if the study roster has no SUBJ-009 or if the laboratory file is expected to contain only the three listed participants. It may reflect an omitted roster entry, an incorrect mapping, or an out-of-scope record; the table alone cannot decide which.
A second check asks whether any one source-and-ID pair maps to multiple canonical subjects. If, for example, the crosswalk also contained (Laboratory, L503) mapped to SUBJ-003, the pair would have two destinations and would violate the one-mapping-per-source-ID rule. The discrepancy should be resolved from source documentation before combining records; choosing one mapping arbitrarily would conceal the identity problem.
Why the Roster Check Works—and What It Cannot Prove
The roster check follows directly from the definition of a one-row-per-subject roster. Let \(f\) assign to each roster row its usable identifier. If \(f\) is injective, then distinct rows have distinct identifiers. If identifiers are also present on every row, the number of distinct identifiers equals the number of rows. Conversely, if two rows share an identifier, \(f\) is not injective and the roster cannot distinguish those rows using that identifier.
The condition is necessary for a correctly constructed roster, but it is not sufficient to verify identity. For example, swapping two participants’ otherwise unique IDs preserves the number of distinct values while assigning IDs incorrectly. Automated checks establish structural properties of the values; comparison with authoritative source records establishes whether the assignments are correct.
Diagnostics, Alternatives, and Limitations
Useful diagnostics include counts of blank and placeholder values, counts of distinct IDs within each stated scope, duplicate rows in a one-row-per-subject roster, and source IDs with more than one canonical mapping. Review both exceptions and the expected overlap between files. A clean count can still hide a wrong mapping, so retain an audit trail of corrections and the source evidence used to make them.
There are several reasonable identifier designs, but each has limits:
- Use a source-local ID alone. This is simple when the source guarantees uniqueness over the full intended scope. It fails when IDs can be reused by sites, systems, or study parts.
- Combine the local ID with a namespace. A site or source-system prefix can distinguish reused local values if the namespace is reliable and stable. Inconsistent site labels or missing context can still create ambiguity.
- Assign a canonical study ID and keep a crosswalk. This supports harmonization across sources and keeps source values available for tracing. The crosswalk itself must be access-controlled as appropriate, complete, and versioned; a canonical ID does not correct an unsupported source linkage.
Common failure modes include converting IDs to numbers, treating every repeated subject ID in a record file as a duplicate error, assuming the same raw ID always means the same subject across sites, and silently assigning a new ID to a row with a missing value. Each can either erase distinguishing information or create a false link. A further limitation is that a uniqueness test cannot detect an ID that is unique but belongs to the wrong participant. That requires reconciliation with authoritative records.
Check Your Understanding
For each question, identify the applicable check and explain what its result can establish.
- A roster has 48 rows, no missing IDs, and 48 distinct IDs. What does this demonstrate, and what does it not demonstrate?
- A repeated-record file has 300 rows and 30 distinct subject IDs. Is the subject ID necessarily non-unique in error?
- A source system reuses IDs at each site. What values should define the scope of a uniqueness check?
- A file has 2 missing subject IDs among 80 rows. Calculate the row-level missingness percentage.
- One laboratory ID maps to two canonical IDs in a crosswalk. What is the problem, and what is an appropriate next step?
Solutions. (1) The roster has a complete, distinct ID on every row, so it passes the structural completeness and uniqueness checks. It does not prove that the IDs are assigned to the correct people. (2) No. Multiple records per subject are expected in a repeated-record file; check that required rows have IDs and reconcile the distinct IDs to the roster. (3) Use the site-and-source-ID pair, provided the site namespace is reliable and the source rule guarantees local uniqueness. (4) \((2/80)\times100\%=2.5\%\) of rows are missing an ID; this is not necessarily the percentage of subjects. (5) The source identifier has conflicting destinations, violating the one-mapping-per-source-ID rule. Pause reconciliation and resolve the mapping using authoritative source documentation rather than choosing a destination arbitrarily.