Generate a draft study config YAML from a directory of ADaM files.
Source:R/generate_study_config.R
generate_study_config.RdScans a directory of .sas7bdat files, infers dataset_type and
per-dataset glimpse arguments using CDISC filename and column-name
conventions, and writes a draft YAML config suitable for simulate_study().
Inferred fields are tagged with inline # REVIEW comments where the signal
is weak so users know what to verify before running the simulation.
Usage
generate_study_config(
adam_dir,
output_dir,
config_yaml_name = "synadam_config.yaml",
seed = 123
)Arguments
- adam_dir
character(1)- directory containing.sas7bdatfiles.- output_dir
character(1)- directory that both the generated config YAML and the synthetic.rdsoutputs are written to. Created recursively if it does not exist. This same path is recorded as the top-leveloutput_dirfield in the YAML, sosimulate_study()writes itssyn_*.rdsfiles alongside the config.- config_yaml_name
character(1)- filename for the generated config withinoutput_dir. Defaults to"synadam_config.yaml". If the file already exists, it is silently overwritten.- seed
integer(1)/numeric(1)orNULL- value to write for the top-levelseedfield in the YAML. Defaults to123. IfNULL, a"REVIEW: ..."placeholder is written instead.
Details
Only files whose basename matches ad*.sas7bdat (case-insensitive) are
considered. Any other files in adam_dir are skipped with a single
warning listing them.
Detection rules
Filename match (case-insensitive, basename without extension):
starts with
adsl->adslstarts with
adae/adcm/admh/addv->occdsstarts with
adtte->tteany other name (including
ad*) -> fall through to column inspection
Column inspection rules (checked in order; USUBJID is required in
every ADaM dataset, so it is not used as a discriminator). ADSL is
classified from the filename only - any non-adsl* file that lacks
BDS/TTE/OCCDS column signatures falls through to "REVIEW":
has
PARAM->bds(checked before CNSR so oncology hybrid datasets like ADRECIST that carry TTE-derived parameters inline classify as the longitudinal BDS they actually are)has
CNSR->tte(CNSR is the only structurally required TTE variable in ADaM;EVNTDESCis conventional but not universal)has any
*SEQcolumn ->occdsotherwise ->
"REVIEW"placeholder + warning
Errors if no ADSL file is detected; simulate_study() requires exactly
one. If multiple ADSL candidates are detected, a file named exactly
adsl.sas7bdat (case-insensitive) is preferred; otherwise the
alphabetically-first candidate is used. The picked file is kept and the
rest are dropped with a warning.
Column-role detection
Within a classified dataset, the column-role inference picks up:
id_cols:USUBJIDandSUBJIDwhen present.treatment_cols(ADSL):ACTARM,ACTARMCD,ARM,ARMCD,TRTSEQP,TRTSEQAand anyTRT##A/TRT##AN/TRT##AL/TRT##P/TRT##PN/TRT##PLmatches, plusTRT##(A|P)GR\d*andTRT##(A|P)GR\d*Ngroup variants.visit_cols(BDS):AVISIT,AVISITN,VISIT,VISITNUM,ATPT,ATPTNwhen present.param_cols(BDS, TTE):PARAM,PARAMCD, and anyPARCAT*columns.seq_col(OCCDS): the first known domain-coded*SEQcolumn (AESEQ,CMSEQ,MHSEQ,PRSEQ,EXSEQ,DSSEQ); falls back to the first*SEQcolumn if none of those are present.censor_cols(TTE):CNSR,EVNTDESC,CNSDTDSC- only emitted when two or more of these are detected. A singleCNSRflows through as a regular column andcensor_colsis omitted.ordered_col_sets: X/XN/XL groups where two or three variants of a base column name co-exist.
What is NOT auto-inferred
Some config decisions are opinionated and intended to be pruned or extended by the user after generation:
flag_colsemits every*FLcolumn found. The user is expected to trim this list down to the flags they want to preserve.Non-FL flag-like indicators (e.g.
AESER) are not detected.Ordered column sets that share semantics but not naming (e.g.
AEBODSYS/AEDECOD) are not auto-paired; add them by hand.For BDS and TTE datasets
param_colsauto-includesPARAM,PARAMCD, and anyPARCAT*columns present, but NOTPARAMTYPorPARAMN; add these manually if relevant.For BDS, OCCDS, and TTE datasets
ordered_col_setsexcludes any column also present in the chosen ADSL. ADSL-shared columns are pulled in via the ADSL spine at simulation time, so listing them here would duplicate the column.