Feature Idea
Summary
I would like to contribute a derive_epoch() function to automate EPOCH variable derivation for SDTM domains. This function compares date variables from any SDTM domain (AE, VS, CM, EX, LB, etc.) against Subject Elements (SE) domain date ranges (SESTDTC/SEENDTC) to assign the appropriate EPOCH value.
Functionality
Function Signature
derive_epoch(
raw_dat,
se_dat,
tgt_var,
id_vars = "USUBJID"
)
Key Features
Universal domain support using parameterized date variable
Handles ISO8601 datetime format (strips time components)
Correct boundary date assignment
Missing SEENDTC imputation (prevents overlapping intervals)
Open-ended epoch support (final epochs without end dates)
Edge case handling (returns NA for unmatched dates/subjects)
Preserves original row order
Example Usage
# Derive EPOCH for AE domain
ae_with_epoch <- derive_epoch(
raw_dat = ae,
se_dat = se_domain,
tgt_var = "AESTDTC"
)
Implementation Status
Complete implementation ready for contribution:
✅ Function with comprehensive roxygen2 documentation
✅ 25 unit tests (all passing)
✅ Example datasets across multiple domains
✅ Follows sdtm.oak package conventions
Known Limitations
Documented limitations requiring pre-processing:
Partial ISO8601 dates (year-month only)
Unknown date components
Timezone information ignored
Next Steps
If this aligns with the sdtm.oak roadmap, I'm ready to submit a pull request with the complete implementation and address any review feedback.
Please let me know if you have questions or would like to see the implementation details.
### Relevant Input
_No response_
### Relevant Output
_No response_
### Reproducible Example/Pseudo Code
_No response_
Feature Idea
Summary
I would like to contribute a
derive_epoch()function to automate EPOCH variable derivation for SDTM domains. This function compares date variables from any SDTM domain (AE, VS, CM, EX, LB, etc.) against Subject Elements (SE) domain date ranges (SESTDTC/SEENDTC) to assign the appropriate EPOCH value.Functionality
Function Signature