Learn R Programming

sdtmchecks

The sdtmchecks package contains functions to identify common data issues in SDTM data. These checks are intended to be generalizable, actionable, and meaningful for analysis.

Installation

CRAN

You can install {sdtmchecks} from CRAN:

install.packages("sdtmchecks")

Development version (devel branch)

The development version (based on the default devel branch) can be installed via:

install.packages("sdtmchecks", repos = "https://pharmaverse.r-universe.dev")  

Or, via GitHub repo pharmaverse/sdtmchecks@HEAD:

# install.packages("devtools")
devtools::install_github("pharmaverse/sdtmchecks")

# Note that `ref = "devel"` is not needed since devel is the default branch

Use the package

The Get started page walks you through how the package can be used.

Data checks in the package

To search available data check functions, please see this search page.

The main data check functions of the package are saved as R program files beginning with “check_…” and are referenced under the Data Checks portion of the Reference page.

SDTM version

This package aims to be SDTM version agnostic and does not require users to specify the version.

Contributing

This package has been developed internally at Roche since 2014. There may be areas where the checks expect Roche-specific SDTM implementation choices. Proposed additions or modifications should attempt to maintain generalizability for slightly different data standards across companies. For examples on how to do so and to learn more about contributing in general, please refer to the Writing a New Check page.

If you have an idea for a new check but no time for development, please open an issue.

FAQs

The package FAQs may provide additional information you are looking for. If not, please feel free to post your question as an issue.

Copy Link

Version

Install

install.packages('sdtmchecks')

Monthly Downloads

192

Version

1.0.0

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Will Harris

Last Published

July 12th, 2024

Functions in sdtmchecks (1.0.0)

check_ae_ds_partial_death_dates

Check for partial death dates in AE and DS
check_ae_aeout_aeendtc_nonfatal

Check for non-fatal AEs with inconsistent AEOUT and AEENDTC
check_ae_death_ds_discon

Check if death in AE then there should be a study discon form
check_ae_aestdtc_after_aeendtc

Check that all AE start dates are on or before AE end dates
check_ae_aerel

Check for AEREL1 - AERELN when AEREL is missing and when AEREL is unexpected
check_ae_aesdth_aedthdtc

Check AEs with AESDTH of "Y" but No AEDTHDTC Value
check_ae_death

Check for Grade 5 AE death variable consistency
check_ae_aestdtc_after_dd

Check for AE dates occurring after death date
check_ae_dup

Check for duplicate AE entries
check_ae_aetoxgr

Check for missing AETOXGR and/or AESEV values
check_cm_cmindc

Check for concomitant medication indication with text string "PROPHYL" when not given for prophylaxis
check_cm_cmlat

Check if ocular concomitant medication has laterality missing or laterality field is populated but route is not eye-related.
check_ae_withdr_ds_discon

Check if an AE leading to drug being withdrawn is reflected in DS
check_ae_fatal

Check for death variable consistency when AEOUT=="FATAL"
check_cm_cmlat_prior_ocular

Check if ocular concomitant medication has laterality missing for specific "PRIOR OCULAR THERAPIES AND TREATMENTS" (or similar names) CRF page.
check_cm_missing_month

Check for conmed dates with year and day known but month unknown
check_ce_missing_month

Check for clinical events dates with year and day known but month unknown
check_cm_cmdecod

Check for missing CMDECOD values
check_ds_dsdecod_death

Check for study discontinuation record if death indicated
check_dd_ae_aedthdtc_ds_dsstdtc

Check if death date is the same in AE and DS domains
check_ds_ae_discon

Check for treatment discontinuation consistency between DS and AE
check_dd_ae_aeout_aedthdtc

Check if there is a death date and AEOUT='FATAL' agreement
check_dm_usubjid_ae_usubjid

Check patients in the DM dataset who do not have records in the AE dataset
check_dm_usubjid_dup

Check duplicate patient records in DM based on USUBJID
check_dm_armcd

Check for missing ARM or ARMCD values in DM
check_dm_dthfl_dthdtc

Check that when DM.DTHFL is Y, DM.DTHDTC does not have a missing value, and vice versa
check_ds_ex_after_discon

Check for patients who had Start/End date of treatment after study discontinuation date
check_ds_multdeath_dsstdtc

Check DS with multiple death records with death dates, where death dates do not match
check_ds_sc_strat

Check if randomized patients are missing stratification factor data
check_dv_ae_aedecod_covid

Check for consistency between DV and AE for COVID-19 events
check_ds_dsscat

Check for patients with more than one study discontinuation records
check_dm_age_missing

Check for patients with suspicious age values
check_ds_dsdecod_dsstdtc

Check DS with death record but no death date
check_ex_exstdtc_after_exendtc

Check that all exposure start dates are on or before exposure end dates
check_ex_exoccur_mis_exdose_nonmis

Check for missing EXOCCUR but EXDOSE not missing
check_dm_ae_ds_death

Check if death reported in DM then death indicator also present in DS or AE
check_ex_exstdtc_after_dd

Check for EX dates occurring after death date
check_ex_exstdtc_visit_ordinal_error

Check that all EX start dates are earlier than last visit's (possible datetime data entry error)
check_ds_dsterm_death_due_to

Check missing cause of death information in DS
check_dv_covid

Check for consistency in COVID-19 DV variables, DVREAS and DVEPRELI
check_dd_death_date

Check if patient with Death due to AE also has Death record in DS
check_ec_sc_lat

Check if Study Drug is not administered in the Study Eye
check_lb_lbstresc_char

Check LBORRES/LBSTRESC populated with number beginning with character '>' or '<', which will yield missing AVAL in ADaM and records will be omitted in analyses such as Hy's Law
check_lb_lbstresu

Check for missing lab units (LBSTRESU)
check_lb_lbstresn_missing

Check missing standard lab values (LBSTRESN/LBSTRESC)
check_ex_visit

Check for missing EX.VISIT
check_dm_actarm_arm

Check DM where ARM is not equal to ACTARM
check_ds_duplicate_randomization

Check for duplicate randomization records for a patient
check_ex_exoccur_exdose_exstdtc

Check for Invalid EXDOSE (Dose per Administration) and Missing/Incomplete EXSTDTC (Start Date) Values for valid exposures
check_ex_exdosu

Check for missing EXDOSU records
check_ex_dup

Check for duplicate EX records
check_lb_missing_month

Check for lab dates with year and day known but month unknown
check_ex_exdose_exoccur

Check for Missing EXDOSE.
check_eg_egdtc_visit_ordinal_error

Check that all ECG datetimes are earlier than last visit's (possible datetime data entry error)
check_oe_bcva_4m_vs_1m_req

Check if 1m BCVA test is completed per BCVA 4m result
check_lb_lbdtc_visit_ordinal_error

Check that all LB dates are duplicated or earlier than last visit's (possible datetime data entry error)
check_pr_prlat

Check if ocular procedures/surgeries has laterality missing for CRF pages which contain the word "OCULAR" (and not "NON-OCULAR").
check_lb_lbstnrlo_lbstnrhi

Check for missing lab reference ranges (LBSTNRLO, LBSTNRHI)
check_ex_exdose_pos_exoccur_no

Check for EXDOSE>0 When EXOCCUR is not "Y"
check_qs_dup

Check for multiple dates at the same visit in QS
check_ex_extrt_exoccur

Check for EX records where EXTRT is missing
check_mi_mispec

Check for missing values in the MISPEC variable
check_ex_infusion_exstdtc_exendtc

Check that an infusion drug has same start/end exposure dates, also including missing start/end dates
check_qs_qsdtc_after_dd

Check for QS dates occurring after death date
check_qs_qsdtc_visit_ordinal_error

Check that all QS dates are duplicated or earlier than last visit's (possible datetime data entry error)
check_lb_lbdtc_after_dd

Check for LB dates occurring after death date
check_oe_sc_lat_count_fingers

Check if Post Treatment Count Fingers in Study Eye laterality does not match with Subject Characteristics Study Eye laterality
check_mh_missing_month

Check for MH dates with year and day known but month unknown
check_pr_missing_month

Check for procedure dates with year and day known but month unknown
check_rs_rsdtc_across_visit

Check RS records where the same date occurs across multiple visits
check_oe_bcva_1m_late_early_tot

Check if 1m BCVA test stops too late, too early and has correct total
check_oe_bcva_4m_late_early_tot

Check if 4m BCVA test stops too late, too early and has correct total
check_rs_rscat_rsscat

Check for patients with populated RSSCAT but missing RSCAT.
check_ss_ssstat_ssorres

Check for non-missing SSORRES if SSSTAT is NOT DONE
check_qs_qsstat_qsstresc

Check for non-missing QSSTRESC if QSSTAT is NOT DONE
check_qs_qsstat_qsreasnd

Check to confirm that there is a reason for a questionnaire being marked as not done
check_ss_ssdtc_dead_dthdtc

Check non-missing DEAD status date in SS and an according DM record with death date where status date is greater or equal to death date
check_tr_trdtc_across_visit

Check TR Longest Diameter Records where the same date occurs across multiple visits
check_tr_dup

Check for duplicate TR records
check_ts_sstdtc_ds_consent

Check for missing SSTDTC (Study Start Date) in TS
check_tr_trstresn_ldiam

Check for TR records with missing TRSTRESN for Longest Diameter (LDIAM)
check_tr_trdtc_visit_ordinal_error

Check that all TR dates by INV are duplicated or earlier than last visit's (possible date entry error)
check_rs_rsdtc_visit

Check missing RSDTC and VISIT
check_oe_bcva_tot_mismatch

Check mismatch between Derived BCVA Total Score & Total BCVA Score from Data
check_rs_rsdtc_visit_ordinal_error

Check that all RS dates for INV Overall Response are duplicated or earlier than last visit's (possible date entry error)
check_ts_cmdict

Check for missing WHODrug version in TS
check_ts_aedict

Check for missing MedDRA version in TS
check_sc_dm_seyeselc

Check SC Study Eye Selection assignments among DM patients
check_ss_ssdtc_dead_ds

Check non-missing DEAD status date in SS and non-missing according DS record with death date where status date is greater or equal to death date
check_ss_ssdtc_alive_dm

Check non-missing last ALIVE status date in SS is before than death date in DM
check_sc_dm_eligcrit

Check SC Eye Meeting Eligibility Criteria assignments among DM patients
check_tu_tuloc_missing

Check for missing TULOC values
convert_var_to_ascii

Remove non-ASCII characters from reported term in order for Pandoc to create PDF file
check_vs_vsdtc_after_dd

Check for VS dates occurring after death date
check_tu_tudtc_visit_ordinal_error

Check that all TU dates are duplicated or earlier than last visit's (possible datetime data entry error)
check_tu_rs_new_lesions

Check for consistency between new lesions and overall PD response
check_tu_tudtc

Check for missing TUDTC values
%lacks_all%

Check if data frame is missing any of the specified variables
impute_day01

Add day of "01" to dates that are in the format of "yyyy-mm"
is_sas_na

Check if the elements could be of any SAS missing data variant
%lacks_any%

Check if data frame has at least one variable from a set of specified variables
check_vs_height

Check for missing height values
check_vs_sbp_lt_dbp

Check that DBP is not higher than SBP in VS
check_tu_tudtc_across_visit

Check TU Records where the same date occurs across multiple visits
fail

Fail object
dtc_dupl_early

Check if start dates are duplicated or earlier than prior visit date
create_R_script

Create .R file with sdtmchecks function calls
sdtmchecksmeta

Metadata for sdtmchecks
sdtmchecks-package

sdtmchecks: Data Quality Checks for Study Data Tabulation Model (SDTM) Datasets
diff_reports

Create a sdtmchecks list object with column indicating whether the issue was previously seen
pass

Pass object
nickname

Nickname for package version
%has_all%

Check if data frame has all specified variables
%has_any%

Check if data frame has at least one of the specified variables
run_check

Run a single check in sdtmchecks package
run_all_checks

Run all data checks in sdtmchecks package using parallel processing
truncate_var_strings

Utility function to truncate data in var_name
roche_derive_rave_row

Utility function to obtain Rave form name and row number
report_to_xlsx

Save report as an xlsx file
missing_month

Function to check if month is missing while year and day are non-missing (i.e. would be in the format of "yyyy---dd")
lacks_msg

Check data frame for mandatory variables and specify which are missing in message
check_ae_aeacn_ds_disctx_covid

Check for COVID-19 AE with DRUG WITHDRAWN action without "ADVERSE EVENT" for DS Trt Discon
check_ae_aeacnoth_ds_disctx

Check if, whenever a patient experiences an AE leading to study discontinuation, they also have a DS record indicating this.
check_ae_aeacnoth

Check for null AEACNOT1/2 when AEACNOTH = 'MULTIPLE'
check_ae_aedthdtc_aesdth

Check AEs with AEDTHDTC value but AESDTH not "Y"
check_ae_aedecod

Check for missing AEDECOD values
check_ae_aedthdtc_ds_death

Check for missing AEDTHDTC where DS indicates death due to AE
check_ae_aeout

Check for inconsistency between AE outcome (AEOUT) and death date (AEDTHDTC)
check_ae_aeout_aeendtc_aedthdtc

Check for AE outcome (AEOUT) of 'FATAL' with non-missing resolution date that is not equal to the death date
check_ae_aeacnoth_ds_stddisc_covid

Check for COVID-19 AE leading to Study Discon without DS Study Discon
check_ae_aelat

Check if AESOC has Eye, and Affected Eye is missing