| Title: | 'SAS' IF Style Data Step Logic for Data Tables |
|---|---|
| Description: | Provides 'SAS'-style IF/ELSE chains, independent IF rules, and DELETE logic for 'data.table', enabling clinical programmers to express Study Data Tabulation Model (SDTM) and Analysis Data Model (ADaM)-style derivations in familiar SAS-like syntax. Methods are informed by clinical data standards described in CDISC SDTM and ADaM implementation guides. See <https://www.cdisc.org/standards/foundational/sdtm> and <https://www.cdisc.org/standards/foundational/adam>. |
| Authors: | Thiyagarajan Chandrasekaran [aut, cre] |
| Maintainer: | Thiyagarajan Chandrasekaran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-05-20 09:40:25 UTC |
| Source: | https://github.com/chandrt23-lang/sasif |
Provides SAS-style IF/ELSE chains, independent IF rules, and DELETE logic for fast, vectorized transformations on data.table objects. This enables clinical programmers to express SDTM and ADaM-style derivations in familiar SAS-like syntax while leveraging data.table performance.
data_step(dt, ..., copy = TRUE)data_step(dt, ..., copy = TRUE)
dt |
A data.table. |
... |
One or more rule objects created by if_do(), else_if_do(), else_do(), if_independent(), or delete_if(). |
copy |
Logical. If TRUE (default), a copy of dt is modified and returned. |
A data.table with applied transformations.
library(data.table) dt <- data.table( AGE = c(40, 60, 80), SEX = c("M", "F", "M") ) out <- data_step( dt, if_do(AGE <= 45, GROUP = 1), else_if_do(AGE <= 70, GROUP = 2), else_do(GROUP = 3), if_independent(SEX == "M", MALE = 1) ) outlibrary(data.table) dt <- data.table( AGE = c(40, 60, 80), SEX = c("M", "F", "M") ) out <- data_step( dt, if_do(AGE <= 45, GROUP = 1), else_if_do(AGE <= 70, GROUP = 2), else_do(GROUP = 3), if_independent(SEX == "M", MALE = 1) ) out
Creates a DELETE rule to remove rows from the data.table when condition is TRUE.
delete_if(condition)delete_if(condition)
condition |
Logical condition evaluated on the data.table. |
A rule object for data_step().
Creates an ELSE rule for use inside data_step().
else_do(...)else_do(...)
... |
Named assignments to apply when no previous IF/ELSE IF matched. |
A rule object for data_step().
Creates an ELSE IF rule for use inside data_step().
else_if_do(condition, ...)else_if_do(condition, ...)
condition |
Logical condition evaluated on the data.table. |
... |
Named assignments to apply when condition is TRUE. |
A rule object for data_step().
Creates a mutually exclusive IF rule for use inside data_step().
if_do(condition, ...)if_do(condition, ...)
condition |
Logical condition evaluated on the data.table. |
... |
Named assignments to apply when condition is TRUE. |
A rule object for data_step().
Creates an independent IF rule that is evaluated regardless of IF/ELSE chains.
if_independent(condition, ...)if_independent(condition, ...)
condition |
Logical condition evaluated on the data.table. |
... |
Named assignments to apply when condition is TRUE. |
A rule object for data_step().