Skip to contents

Add Anatomical Therapeutic Chemical class variables from FACM to ADCM

Usage

derive_vars_atc(
  dataset,
  dataset_facm,
  by_vars = exprs(USUBJID, CMREFID = FAREFID),
  value_var = FASTRESC
)

Arguments

dataset

Input dataset

The variables specified by the by_vars parameter are required

dataset_facm

FACM dataset

The variables specified by the by_vars and value_var parameters, FAGRPID and FATESTCD are required

by_vars

Keys used to merge dataset_facm with dataset

Permitted Values: list of variables

value_var

The variable of dataset_facm containing the values of the transposed variables

Default: FASTRESC

Value

The input dataset with ATC variables added

See also

Examples

library(tibble)

cm <- tribble(
  ~USUBJID, ~CMGRPID, ~CMREFID, ~CMDECOD,
  "BP40257-1001", "14", "1192056", "PARACETAMOL",
  "BP40257-1001", "18", "2007001", "SOLUMEDROL",
  "BP40257-1002", "19", "2791596", "SPIRONOLACTONE"
)
facm <- tribble(
  ~USUBJID, ~FAGRPID, ~FAREFID, ~FATESTCD, ~FASTRESC,
  "BP40257-1001", "1", "1192056", "CMATC1CD", "N",
  "BP40257-1001", "1", "1192056", "CMATC2CD", "N02",
  "BP40257-1001", "1", "1192056", "CMATC3CD", "N02B",
  "BP40257-1001", "1", "1192056", "CMATC4CD", "N02BE",
  "BP40257-1001", "1", "2007001", "CMATC1CD", "D",
  "BP40257-1001", "1", "2007001", "CMATC2CD", "D10",
  "BP40257-1001", "1", "2007001", "CMATC3CD", "D10A",
  "BP40257-1001", "1", "2007001", "CMATC4CD", "D10AA",
  "BP40257-1001", "2", "2007001", "CMATC1CD", "D",
  "BP40257-1001", "2", "2007001", "CMATC2CD", "D07",
  "BP40257-1001", "2", "2007001", "CMATC3CD", "D07A",
  "BP40257-1001", "2", "2007001", "CMATC4CD", "D07AA",
  "BP40257-1001", "3", "2007001", "CMATC1CD", "H",
  "BP40257-1001", "3", "2007001", "CMATC2CD", "H02",
  "BP40257-1001", "3", "2007001", "CMATC3CD", "H02A",
  "BP40257-1001", "3", "2007001", "CMATC4CD", "H02AB",
  "BP40257-1002", "1", "2791596", "CMATC1CD", "C",
  "BP40257-1002", "1", "2791596", "CMATC2CD", "C03",
  "BP40257-1002", "1", "2791596", "CMATC3CD", "C03D",
  "BP40257-1002", "1", "2791596", "CMATC4CD", "C03DA"
)

derive_vars_atc(cm, facm)
#> # A tibble: 5 x 8
#>   USUBJID      CMGRPID CMREFID CMDECOD        ATC1CD ATC2CD ATC3CD ATC4CD
#>   <chr>        <chr>   <chr>   <chr>          <chr>  <chr>  <chr>  <chr> 
#> 1 BP40257-1001 14      1192056 PARACETAMOL    N      N02    N02B   N02BE 
#> 2 BP40257-1001 18      2007001 SOLUMEDROL     D      D10    D10A   D10AA 
#> 3 BP40257-1001 18      2007001 SOLUMEDROL     D      D07    D07A   D07AA 
#> 4 BP40257-1001 18      2007001 SOLUMEDROL     H      H02    H02A   H02AB 
#> 5 BP40257-1002 19      2791596 SPIRONOLACTONE C      C03    C03D   C03DA