Movatterモバイル変換


[0]ホーム

URL:


Creating ADSL

Introduction

This article describes creating anADSL ADaM. Examplesare currently presented and tested usingDM,EX ,AE,LB andDSSDTM domains. However, other domains could be used.

Note:All examples assume CDISC SDTM and/or ADaMformat as input unless otherwise specified.

Programming Flow

Read in Data

To start, all data frames needed for the creation ofADSL should be read into the environment. This will be acompany specific process. Some of the data frames needed may beDM,EX,DS,AE, andLB.

For example purpose, the CDISC Pilot SDTM datasets—which are includedin{pharmaversesdtm}—are used.

library(admiral)library(dplyr,warn.conflicts =FALSE)library(pharmaversesdtm)library(lubridate)library(stringr)dm<- pharmaversesdtm::dmds<- pharmaversesdtm::dsex<- pharmaversesdtm::exae<- pharmaversesdtm::aelb<- pharmaversesdtm::lbdm<-convert_blanks_to_na(dm)ds<-convert_blanks_to_na(ds)ex<-convert_blanks_to_na(ex)ae<-convert_blanks_to_na(ae)lb<-convert_blanks_to_na(lb)

TheDM domain is used as the basis forADSL:

adsl<- dm%>%select(-DOMAIN)
USUBJIDRFSTDTCCOUNTRYAGESEXRACEETHNICARMACTARM
01-701-10152014-01-02USA63FWHITEHISPANIC OR LATINOPlaceboPlacebo
01-701-10232012-08-05USA64MWHITEHISPANIC OR LATINOPlaceboPlacebo
01-701-10282013-07-19USA71MWHITENOT HISPANIC OR LATINOXanomeline High DoseXanomeline High Dose
01-701-10332014-03-18USA74MWHITENOT HISPANIC OR LATINOXanomeline Low DoseXanomeline Low Dose
01-701-10342014-07-01USA77FWHITENOT HISPANIC OR LATINOXanomeline High DoseXanomeline High Dose
01-701-10472013-02-12USA85FWHITENOT HISPANIC OR LATINOPlaceboPlacebo
01-701-1057NAUSA59FWHITEHISPANIC OR LATINOScreen FailureScreen Failure
01-701-10972014-01-01USA68MWHITENOT HISPANIC OR LATINOXanomeline Low DoseXanomeline Low Dose
01-701-11112012-09-07USA81FWHITENOT HISPANIC OR LATINOXanomeline Low DoseXanomeline Low Dose
01-701-11152012-11-30USA84MWHITENOT HISPANIC OR LATINOXanomeline Low DoseXanomeline Low Dose

Derive Period, Subperiod, and Phase Variables(e.g. APxxSDT,APxxEDT, …)

See the“Visit and PeriodVariables” vignette for more information.

If the variables are not derived based on a period reference dataset,they may be derived at a later point of the flow. For example, phaseslike “Treatment Phase” and “Follow up” could be derived based ontreatment start and end date.

Derive Treatment Variables (TRT0xP,TRT0xA)

The mapping of the treatment variables is left to the ADaMprogrammer. An example mapping for a study without periods may be:

adsl<- dm%>%mutate(TRT01P = ARM,TRT01A = ACTARM)

For studies with periods see the“Visit and Period Variables”vignette.

Derive/Impute Numeric Treatment Date/Time and Duration(TRTSDTM,TRTEDTM,TRTDURD)

The functionderive_vars_merged() can be used to derivethe treatment start and end date/times using theex domain.A pre-processing step forex is required to convert thevariableEXSTDTC andEXSTDTC to datetimevariables and impute missing date or time components. Conversion andimputation is done byderive_vars_dtm().

Example calls:

# impute start and end time of exposure to first and last respectively,# do not impute dateex_ext<- ex%>%derive_vars_dtm(dtc = EXSTDTC,new_vars_prefix ="EXST"  )%>%derive_vars_dtm(dtc = EXENDTC,new_vars_prefix ="EXEN",time_imputation ="last"  )#> The default value of `ignore_seconds_flag` will change to "TRUE" in admiral#> 1.4.0.adsl<- adsl%>%derive_vars_merged(dataset_add = ex_ext,filter_add = (EXDOSE>0|      (EXDOSE==0&str_detect(EXTRT,"PLACEBO")))&!is.na(EXSTDTM),new_vars =exprs(TRTSDTM = EXSTDTM,TRTSTMF = EXSTTMF),order =exprs(EXSTDTM, EXSEQ),mode ="first",by_vars =exprs(STUDYID, USUBJID)  )%>%derive_vars_merged(dataset_add = ex_ext,filter_add = (EXDOSE>0|      (EXDOSE==0&str_detect(EXTRT,"PLACEBO")))&!is.na(EXENDTM),new_vars =exprs(TRTEDTM = EXENDTM,TRTETMF = EXENTMF),order =exprs(EXENDTM, EXSEQ),mode ="last",by_vars =exprs(STUDYID, USUBJID)  )

This call returns the original data frame with the columnTRTSDTM,TRTSTMF,TRTEDTM, andTRTETMF added. Exposure observations with incomplete dateand zero doses of non placebo treatments are ignored. Missing time partsare imputed as first or last for start and end date respectively.

The datetime variables returned can be converted to dates using thederive_vars_dtm_to_dt() function.

adsl<- adsl%>%derive_vars_dtm_to_dt(source_vars =exprs(TRTSDTM, TRTEDTM))

Now, thatTRTSDT andTRTEDT are derived,the functionderive_var_trtdurd() can be used to calculatethe Treatment duration (TRTDURD).

adsl<- adsl%>%derive_var_trtdurd()
USUBJIDRFSTDTCTRTSDTMTRTSDTTRTEDTMTRTEDTTRTDURD
01-701-10152014-01-022014-01-022014-01-022014-07-02 23:59:592014-07-02182
01-701-10232012-08-052012-08-052012-08-052012-09-01 23:59:592012-09-0128
01-701-10282013-07-192013-07-192013-07-192014-01-14 23:59:592014-01-14180
01-701-10332014-03-182014-03-182014-03-182014-03-31 23:59:592014-03-3114
01-701-10342014-07-012014-07-012014-07-012014-12-30 23:59:592014-12-30183
01-701-10472013-02-122013-02-122013-02-122013-03-09 23:59:592013-03-0926
01-701-1057NANANANANANA
01-701-10972014-01-012014-01-012014-01-012014-07-09 23:59:592014-07-09190
01-701-11112012-09-072012-09-072012-09-072012-09-16 23:59:592012-09-1610
01-701-11152012-11-302012-11-302012-11-302013-01-23 23:59:592013-01-2355

Derive Disposition Variables

Disposition Dates (e.g. EOSDT)

The functionsderive_vars_dt() andderive_vars_merged() can be used to derive a dispositiondate. First the character disposition date (DS.DSSTDTC) isconverted to a numeric date (DSSTDT) callingderive_vars_dt(). TheDS dataset is extendedby theDSSTDT variable because the date is required byother derivations, e.g.,RANDDT as well. Then the relevantdisposition date is selected by adjusting thefilter_addargument.

To add the End of Study date (EOSDT) to the inputdataset, a call could be:

# convert character date to numeric date without imputationds_ext<-derive_vars_dt(  ds,dtc = DSSTDTC,new_vars_prefix ="DSST")adsl<- adsl%>%derive_vars_merged(dataset_add = ds_ext,by_vars =exprs(STUDYID, USUBJID),new_vars =exprs(EOSDT = DSSTDT),filter_add = DSCAT=="DISPOSITION EVENT"& DSDECOD!="SCREEN FAILURE"  )

Theds_ext dataset:

USUBJIDDSCATDSDECODDSTERMDSSTDTDSSTDTC
01-701-1015PROTOCOL MILESTONERANDOMIZEDRANDOMIZED2014-01-022014-01-02
01-701-1015DISPOSITION EVENTCOMPLETEDPROTOCOL COMPLETED2014-07-022014-07-02
01-701-1015OTHER EVENTFINAL LAB VISITFINAL LAB VISIT2014-07-022014-07-02
01-701-1023PROTOCOL MILESTONERANDOMIZEDRANDOMIZED2012-08-052012-08-05
01-701-1023DISPOSITION EVENTADVERSE EVENTADVERSE EVENT2012-09-022012-09-02
01-701-1023OTHER EVENTFINAL LAB VISITFINAL LAB VISIT2012-09-022012-09-02
01-701-1023OTHER EVENTFINAL RETRIEVAL VISITFINAL RETRIEVAL VISIT2013-02-182013-02-18
01-701-1028PROTOCOL MILESTONERANDOMIZEDRANDOMIZED2013-07-192013-07-19
01-701-1028DISPOSITION EVENTCOMPLETEDPROTOCOL COMPLETED2014-01-142014-01-14
01-701-1028OTHER EVENTFINAL LAB VISITFINAL LAB VISIT2014-01-142014-01-14

Theadsl dataset:

USUBJIDEOSDT
01-701-10152014-07-02
01-701-10232012-09-02
01-701-10282014-01-14
01-701-10332014-04-14
01-701-10342014-12-30
01-701-10472013-03-29
01-701-1057NA
01-701-10972014-07-09
01-701-11112012-09-17
01-701-11152013-01-23

Thederive_vars_dt() function allows to impute partialdates as well. If imputation is needed and missing days are to beimputed to the first of the month and missing months to the first monthof the year, sethighest_imputation = "M".

Disposition Status (e.g. EOSSTT)

The functionderive_vars_merged() can be used to derivethe End of Study status (EOSSTT) based onDSCAT andDSDECOD fromDS. Therelevant observations are selected by adjusting thefilter_add argument. A function mappingDSDECOD values toEOSSTT values can be definedand used in thenew_vars argument. The mapping for the callbelow is

  • "COMPLETED" ifDSDECOD == "COMPLETED"
  • NA_character_ ifDSDECOD is"SCREEN FAILURE"
  • "DISCONTINUED" otherwise

Example functionformat_eosstt():

format_eosstt<-function(x) {case_when(    x%in%c("COMPLETED")~"COMPLETED",    x%in%c("SCREEN FAILURE")~NA_character_,TRUE~"DISCONTINUED"  )}

The customized mapping functionformat_eosstt() can nowbe passed to the main function. For subjects without a disposition eventthe end of study status is set to"ONGOING" by specifyingthemissing_values argument.

adsl<- adsl%>%derive_vars_merged(dataset_add = ds,by_vars =exprs(STUDYID, USUBJID),filter_add = DSCAT=="DISPOSITION EVENT",new_vars =exprs(EOSSTT =format_eosstt(DSDECOD)),missing_values =exprs(EOSSTT ="ONGOING")  )
USUBJIDEOSDTEOSSTT
01-701-10152014-07-02COMPLETED
01-701-10232012-09-02DISCONTINUED
01-701-10282014-01-14COMPLETED
01-701-10332014-04-14DISCONTINUED
01-701-10342014-12-30COMPLETED
01-701-10472013-03-29DISCONTINUED
01-701-1057NANA
01-701-10972014-07-09COMPLETED
01-701-11112012-09-17DISCONTINUED
01-701-11152013-01-23DISCONTINUED

This call would return the input dataset with the columnEOSSTT added.

If the derivation must be changed, the user can create his/her ownfunction to mapDSDECOD to a suitableEOSSTTvalue.

Disposition Reason(s) (e.g. DCSREAS,DCSREASP)

The main reason for discontinuation is usually stored inDSDECOD whileDSTERM provides additionaldetails regarding subject’s discontinuation (e.g., description of"OTHER").

The functionderive_vars_merged() can be used to derivea disposition reason (along with the details, if required) at a specifictimepoint. The relevant observations are selected by adjusting thefilter_add argument.

To derive the End of Study reason(s) (DCSREAS andDCSREASP), the function will mapDCSREAS asDSDECOD, andDCSREASP asDSTERMifDSDECOD is not"COMPLETED","SCREEN FAILURE", orNA,NAotherwise.

adsl<- adsl%>%derive_vars_merged(dataset_add = ds,by_vars =exprs(USUBJID),new_vars =exprs(DCSREAS = DSDECOD,DCSREASP = DSTERM),filter_add = DSCAT=="DISPOSITION EVENT"&!(DSDECOD%in%c("SCREEN FAILURE","COMPLETED",NA))  )
USUBJIDEOSDTEOSSTTDCSREASDCSREASP
01-701-10152014-07-02COMPLETEDNANA
01-701-10232012-09-02DISCONTINUEDADVERSE EVENTADVERSE EVENT
01-701-10282014-01-14COMPLETEDNANA
01-701-10332014-04-14DISCONTINUEDSTUDY TERMINATED BY SPONSORSPONSOR DECISION (STUDY OR PATIENT DISCONTINUED BY THESPONSOR)
01-701-10342014-12-30COMPLETEDNANA
01-701-10472013-03-29DISCONTINUEDADVERSE EVENTADVERSE EVENT
01-701-1057NANANANA
01-701-10972014-07-09COMPLETEDNANA
01-701-11112012-09-17DISCONTINUEDADVERSE EVENTADVERSE EVENT
01-701-11152013-01-23DISCONTINUEDADVERSE EVENTADVERSE EVENT

This call would return the input dataset with the columnDCSREAS andDCSREASP added.

If the derivation must be changed, the user can define thatderivation in thefilter_add argument of the function tomapDSDECOD andDSTERM to a suitableDCSREAS/DCSREASP value.

The call below mapsDCSREAS andDCREASP asfollows:

  • DCSREAS asDSDECOD ifDSDECODis not"COMPLETED" orNA,NAotherwise
  • DCSREASP asDSTERM ifDSDECODis equal toOTHER,NA otherwise
adsl<- adsl%>%derive_vars_merged(dataset_add = ds,by_vars =exprs(USUBJID),new_vars =exprs(DCSREAS = DSDECOD),filter_add = DSCAT=="DISPOSITION EVENT"&      DSDECOD%notin%c("SCREEN FAILURE","COMPLETED",NA)  )%>%derive_vars_merged(dataset_add = ds,by_vars =exprs(USUBJID),new_vars =exprs(DCSREASP = DSTERM),filter_add = DSCAT=="DISPOSITION EVENT"& DSDECOD%in%"OTHER"  )
USUBJIDEOSDTEOSSTTDCSREASDCSREASP
01-701-10152014-07-02COMPLETEDNANA
01-701-10232012-09-02DISCONTINUEDADVERSE EVENTNA
01-701-10282014-01-14COMPLETEDNANA
01-701-10332014-04-14DISCONTINUEDSTUDY TERMINATED BY SPONSORNA
01-701-10342014-12-30COMPLETEDNANA
01-701-10472013-03-29DISCONTINUEDADVERSE EVENTNA
01-701-1057NANANANA
01-701-10972014-07-09COMPLETEDNANA
01-701-11112012-09-17DISCONTINUEDADVERSE EVENTNA
01-701-11152013-01-23DISCONTINUEDADVERSE EVENTNA

Randomization Date (RANDDT)

The functionderive_vars_merged() can be used to deriverandomization date variable. To map Randomization Date(RANDDT), the call would be:

adsl<- adsl%>%derive_vars_merged(dataset_add = ds_ext,filter_add = DSDECOD=="RANDOMIZED",by_vars =exprs(STUDYID, USUBJID),new_vars =exprs(RANDDT = DSSTDT)  )

This call would return the input dataset with the columnRANDDT is added.

USUBJIDRANDDT
01-701-10152014-01-02
01-701-10232012-08-05
01-701-10282013-07-19
01-701-10332014-03-18
01-701-10342014-07-01
01-701-10472013-02-12
01-701-1057NA
01-701-10972014-01-01
01-701-11112012-09-07
01-701-11152012-11-30

Derive Death Variables

Death Date (DTHDT)

The functionderive_vars_dt() can be used to deriveDTHDT. This function allows the user to impute the date aswell.

Example calls:

adsl<- adsl%>%derive_vars_dt(new_vars_prefix ="DTH",dtc = DTHDTC  )
USUBJIDTRTEDTDTHDTCDTHDTDTHFL
01-701-12112013-01-122013-01-142013-01-14Y
01-701-14422014-04-26NANANA
01-704-14452014-11-012014-11-012014-11-01Y
01-705-1058NANANANA
01-708-13472013-06-18NANANA
01-710-10832013-08-012013-08-022013-08-02Y
01-710-12352013-03-27NANANA
01-715-12072013-05-27NANANA
01-718-11722013-11-29NANANA

This call would return the input dataset with the columnsDTHDT added and, by default, the associated date imputationflag (DTHDTF) populated with the controlled terminologyoutlined in the ADaM IG for date imputations. If the imputation flag isnot required, the user must set the argumentflag_imputation to"none".

If imputation is needed and the date is to be imputed to the firstday of the month/year the call would be:

adsl<- adsl%>%derive_vars_dt(new_vars_prefix ="DTH",dtc = DTHDTC,date_imputation ="first"  )

See alsoDate and Time Imputation.

Cause of Death (DTHCAUS)

The cause of deathDTHCAUS can be derived using thefunctionderive_vars_extreme_event().

Since the cause of death could be collected/mapped in differentdomains (e.g. DS,AE,DD), it isimportant the user specifies the right source(s) to derive the cause ofdeath from.

For example, if the date of death is collected in the AE form whenthe AE is Fatal, the cause of death would be set to the preferred term(AEDECOD) of that Fatal AE, while if the date of death iscollected in theDS form, the cause of death would be setto the disposition term (DSTERM). To achieve this, theevent() objects withinderive_vars_extreme_event() must be specified and definedsuch that they fit the study requirement.

An example call toderive_vars_extreme_event() wouldbe:

adsl<- adsl%>%derive_vars_extreme_event(by_vars =exprs(STUDYID, USUBJID),events =list(event(dataset_name ="ae",condition = AEOUT=="FATAL",set_values_to =exprs(DTHCAUS = AEDECOD),      ),event(dataset_name ="ds",condition = DSDECOD=="DEATH"&grepl("DEATH DUE TO", DSTERM),set_values_to =exprs(DTHCAUS = DSTERM),      )    ),source_datasets =list(ae = ae,ds = ds),tmp_event_nr_var = event_nr,order =exprs(event_nr),mode ="first",new_vars =exprs(DTHCAUS)  )
USUBJIDEOSDTDTHDTCDTHDTDTHCAUS
01-701-12112013-01-142013-01-142013-01-14SUDDEN DEATH
01-704-14452014-11-012014-11-012014-11-01COMPLETED SUICIDE
01-710-10832013-08-022013-08-022013-08-02MYOCARDIAL INFARCTION

The function also offers the option to add some traceabilityvariables (e.g. DTHDOM would store the domain where thedate of death is collected, andDTHSEQ would store thexxSEQ value of that domain). The traceability variablesshould be added to theevent() calls and included in thenew_vars parameter ofderive_vars_extreme_event().

adsl<- adsl%>%select(-DTHCAUS)%>%# remove it before deriving it againderive_vars_extreme_event(by_vars =exprs(STUDYID, USUBJID),events =list(event(dataset_name ="ae",condition = AEOUT=="FATAL",set_values_to =exprs(DTHCAUS = AEDECOD,DTHDOM ="AE",DTHSEQ = AESEQ),      ),event(dataset_name ="ds",condition = DSDECOD=="DEATH"&grepl("DEATH DUE TO", DSTERM),set_values_to =exprs(DTHCAUS = DSTERM,DTHDOM ="DS",DTHSEQ = DSSEQ),      )    ),source_datasets =list(ae = ae,ds = ds),tmp_event_nr_var = event_nr,order =exprs(event_nr),mode ="first",new_vars =exprs(DTHCAUS, DTHDOM, DTHSEQ)  )
USUBJIDTRTEDTDTHDTCDTHDTDTHCAUSDTHDOMDTHSEQ
01-701-12112013-01-122013-01-142013-01-14SUDDEN DEATHAE9
01-704-14452014-11-012014-11-012014-11-01COMPLETED SUICIDEAE1
01-710-10832013-08-012013-08-022013-08-02MYOCARDIAL INFARCTIONAE1

Following the derivation ofDTHCAUS and relatedtraceability variables, it is then possible to derive grouping variablessuch as death categories (DTHCGRx) using standard tidyversecode.

adsl<- adsl%>%mutate(DTHCGR1 =case_when(is.na(DTHDOM)~NA_character_,    DTHDOM=="AE"~"ADVERSE EVENT",str_detect(DTHCAUS,"(PROGRESSIVE DISEASE|DISEASE RELAPSE)")~"PROGRESSIVE DISEASE",TRUE~"OTHER"  ))

Duration Relative to Death

The functionderive_vars_duration() can be used toderive duration relative to death like the Relative Day of Death(DTHADY) or the numbers of days from last dose to death(LDDTHELD).

Example calls:

  • Relative Day of Death
adsl<- adsl%>%derive_vars_duration(new_var = DTHADY,start_date = TRTSDT,end_date = DTHDT  )
  • Elapsed Days from Last Dose to Death
adsl<- adsl%>%derive_vars_duration(new_var = LDDTHELD,start_date = TRTEDT,end_date = DTHDT,add_one =FALSE  )
USUBJIDTRTEDTDTHDTCDTHDTDTHCAUSDTHADYLDDTHELD
01-701-12112013-01-122013-01-142013-01-14SUDDEN DEATH612
01-704-14452014-11-012014-11-012014-11-01COMPLETED SUICIDE1750
01-710-10832013-08-012013-08-022013-08-02MYOCARDIAL INFARCTION121

Derive the Last Date Known Alive (LSTALVDT)

Similarly as for the cause of death (DTHCAUS), the lastknown alive date (LSTALVDT) can be derived from multiplessources usingderive_vars_extreme_event().

An example could be (DTC dates are converted to numeric datesimputing missing day and month to the first):

adsl<- adsl%>%derive_vars_extreme_event(by_vars =exprs(STUDYID, USUBJID),events =list(event(dataset_name ="ae",order =exprs(AESTDTC, AESEQ),condition =!is.na(AESTDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(AESTDTC,highest_imputation ="M"),seq = AESEQ        ),      ),event(dataset_name ="ae",order =exprs(AEENDTC, AESEQ),condition =!is.na(AEENDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(AEENDTC,highest_imputation ="M"),seq = AESEQ        ),      ),event(dataset_name ="lb",order =exprs(LBDTC, LBSEQ),condition =!is.na(LBDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(LBDTC,highest_imputation ="M"),seq = LBSEQ        ),      ),event(dataset_name ="adsl",condition =!is.na(TRTEDT),set_values_to =exprs(LSTALVDT = TRTEDT,seq =0),      )    ),source_datasets =list(ae = ae,lb = lb,adsl = adsl),tmp_event_nr_var = event_nr,order =exprs(LSTALVDT, seq, event_nr),mode ="last",new_vars =exprs(LSTALVDT)  )
USUBJIDTRTEDTDTHDTCLSTALVDT
01-701-10152014-07-02NA2014-07-02
01-701-10232012-09-01NA2012-09-02
01-701-10282014-01-14NA2014-01-14
01-701-10332014-03-31NA2014-04-14
01-701-10342014-12-30NA2014-12-30
01-701-10472013-03-09NA2013-04-07
01-701-10972014-07-09NA2014-07-09
01-701-11112012-09-16NA2012-09-17
01-701-11152013-01-23NA2013-01-23
01-701-11182014-09-09NA2014-09-09

Traceability variables can be added by specifying the variables intheset_values_to parameter of theevent()function.

adsl<- adsl%>%select(-LSTALVDT)%>%# created in the previous callderive_vars_extreme_event(by_vars =exprs(STUDYID, USUBJID),events =list(event(dataset_name ="ae",order =exprs(AESTDTC, AESEQ),condition =!is.na(AESTDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(AESTDTC,highest_imputation ="M"),LALVSEQ = AESEQ,LALVDOM ="AE",LALVVAR ="AESTDTC"        ),      ),event(dataset_name ="ae",order =exprs(AEENDTC, AESEQ),condition =!is.na(AEENDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(AEENDTC,highest_imputation ="M"),LALVSEQ = AESEQ,LALVDOM ="AE",LALVVAR ="AEENDTC"        ),      ),event(dataset_name ="lb",order =exprs(LBDTC, LBSEQ),condition =!is.na(LBDTC),set_values_to =exprs(LSTALVDT =convert_dtc_to_dt(LBDTC,highest_imputation ="M"),LALVSEQ = LBSEQ,LALVDOM ="LB",LALVVAR ="LBDTC"        ),      ),event(dataset_name ="adsl",condition =!is.na(TRTEDT),set_values_to =exprs(LSTALVDT = TRTEDT,LALVSEQ =NA_integer_,LALVDOM ="ADSL",LALVVAR ="TRTEDTM"),      )    ),source_datasets =list(ae = ae,lb = lb,adsl = adsl),tmp_event_nr_var = event_nr,order =exprs(LSTALVDT, LALVSEQ, event_nr),mode ="last",new_vars =exprs(LSTALVDT, LALVSEQ, LALVDOM, LALVVAR)  )
USUBJIDTRTEDTDTHDTCLSTALVDTLALVDOMLALVSEQLALVVAR
01-701-10152014-07-02NA2014-07-02ADSLNATRTEDTM
01-701-10232012-09-01NA2012-09-02LB107LBDTC
01-701-10282014-01-14NA2014-01-14ADSLNATRTEDTM
01-701-10332014-03-31NA2014-04-14LB107LBDTC
01-701-10342014-12-30NA2014-12-30ADSLNATRTEDTM
01-701-10472013-03-09NA2013-04-07LB134LBDTC
01-701-10972014-07-09NA2014-07-09ADSLNATRTEDTM
01-701-11112012-09-16NA2012-09-17LB73LBDTC
01-701-11152013-01-23NA2013-01-23ADSLNATRTEDTM
01-701-11182014-09-09NA2014-09-09ADSLNATRTEDTM

Derive Groupings and Populations

Grouping (e.g. AGEGR1 orREGION1)

Numeric and categorical variables (AGE,RACE,COUNTRY, etc.) may need to be grouped toperform the required analysis.{admiral} provides thederive_vars_cat() function to create such groups. Thisfunction is especially useful if more than one variable needs to becreated for each condition, e.g.,AGEGR1 andAGEGR1N.

Additionally, one needs to be careful when considering the order ofthe conditions in the lookup table. The category is assigned based onthe first match. That meanscatch-all conditions must comeafter specific conditions, e.g. !is.na(COUNTRY) must comeafterCOUNTRY %in% c("CAN", "USA").

# create lookup tablesagegr1_lookup<-exprs(~condition,~AGEGR1,  AGE<18,"<18",between(AGE,18,64),"18-64",  AGE>64,">64",is.na(AGE),"Missing")region1_lookup<-exprs(~condition,~REGION1,  COUNTRY%in%c("CAN","USA"),"North America",!is.na(COUNTRY),"Rest of the World",is.na(COUNTRY),"Missing")
adsl<- adsl%>%derive_vars_cat(definition = agegr1_lookup  )%>%derive_vars_cat(definition = region1_lookup  )

Alternatively, you can also solve this task with customfunctions:

format_agegr1<-function(var_input) {case_when(    var_input<18~"<18",between(var_input,18,64)~"18-64",    var_input>64~">64",TRUE~"Missing"  )}format_region1<-function(var_input) {case_when(    var_input%in%c("CAN","USA")~"North America",!is.na(var_input)~"Rest of the World",TRUE~"Missing"  )}adsl%>%mutate(AGEGR1 =format_agegr1(AGE),REGION1 =format_region1(COUNTRY)  )
USUBJIDAGESEXCOUNTRYAGEGR1REGION1
01-701-101563FUSA18-64North America
01-701-102364MUSA18-64North America
01-701-102871MUSA>64North America
01-701-103374MUSA>64North America
01-701-103477FUSA>64North America
01-701-104785FUSA>64North America
01-701-105759FUSA18-64North America
01-701-109768MUSA>64North America
01-701-111181FUSA>64North America
01-701-111584MUSA>64North America

Population Flags (e.g. SAFFL)

Since the populations flags are mainly company/study specific nodedicated functions are provided, but in most cases they can easily bederived usingderive_var_merged_exist_flag.

An example of an implementation could be:

adsl<- adsl%>%derive_var_merged_exist_flag(dataset_add = ex,by_vars =exprs(STUDYID, USUBJID),new_var = SAFFL,false_value ="N",missing_value ="N",condition = (EXDOSE>0| (EXDOSE==0&str_detect(EXTRT,"PLACEBO")))  )
USUBJIDTRTSDTARMACTARMSAFFL
01-701-10152014-01-02PlaceboPlaceboY
01-701-10232012-08-05PlaceboPlaceboY
01-701-10282013-07-19Xanomeline High DoseXanomeline High DoseY
01-701-10332014-03-18Xanomeline Low DoseXanomeline Low DoseY
01-701-10342014-07-01Xanomeline High DoseXanomeline High DoseY
01-701-10472013-02-12PlaceboPlaceboY
01-701-1057NAScreen FailureScreen FailureN
01-701-10972014-01-01Xanomeline Low DoseXanomeline Low DoseY
01-701-11112012-09-07Xanomeline Low DoseXanomeline Low DoseY
01-701-11152012-11-30Xanomeline Low DoseXanomeline Low DoseY

Derive Other Variables

The users can add specific code to cover their need for theanalysis.

The following functions are helpful for many ADSL derivations:

See alsoGeneric Functions.

Add Labels and Attributes

Adding labels and attributes for SAS transport files is supported bythe following packages:

NOTE: All these packages are in the experimental phase, but thevision is to have them associated with an End to End pipeline under theumbrella of thepharmaverse. An example ofapplying metadata and perform associated checks can be found at thepharmaverse E2Eexample.

Example Script

ADaMSourcing Command
ADSLuse_ad_template("ADSL")

[8]ページ先頭

©2009-2025 Movatter.jp