Learn R Programming

sdtm.terminology (version 2025-3-25)

term_to_code: SDTM term to code

Description

term_to_code() maps SDTM terminology terms to respective C-codes. For mapping terms referring to codelists, use clst_term_to_code() instead.

Usage

term_to_code(term, clst_code)

Value

A character vector of SDTM controlled terminology C-codes. The number of elements returned matches the number of elements in term, i.e. there is a one-to-one correspondence between input and output. Invalid codes in term are mapped to NA.

Arguments

term

A SDTM controlled terminology term (as expected in submissions).

clst_code

Parent codelist code.

See Also

See code_to_term() for the inverse operation.

Examples

Run this code
term_to_code(term = "TENMW101", clst_code = "C141657")

# Both `term` and `clst_code` are vectorized. `clst_code` will be recycled
# to match `term` number of elements.
term_to_code(term = c("TENMW101", "TENMW102"), clst_code = "C141657")

# You may mix codelists as long as `term` and `clst_code` have the same
# number of elements; they will be matched element-wise.
term_to_code(
  term = c("TENMW101", "TENMW102", "TENMW1-Test Grade"),
  clst_code = c("C141657", "C141657", "C141656")
)

# Invalid terms (e.g. `"Gambelas"`) map to `NA`.
term_to_code(term = c("TENMW101", "TENMW102", "Gambelas"), clst_code = "C141657")

Run the code above in your browser using DataLab