powered by
Assigns the "[DOMAIN]SEQ" number by sorting the data set by the specified variables and then grouping by "USUBJID".
"[DOMAIN]SEQ"
"USUBJID"
assign_SEQ(tbl, key_vars, seq_prefix, USUBJID = "USUBJID")
a sorted copy of the tbl data frame with the new SEQ column
tbl
a data frame, the SDTM table
a character vector of the key variables to sort by
a string, the prefix for SEQ as per the spec (usually the two letter domain abbreviation)
a string, the column for the subject ID, USUBJID, default is "USUBJID"
df <- data.frame( USUBJID = paste("Subject", c(rep(1, 3), rep(2, 3))), XXTESTCD = paste("T", rep(c(2, 3, 1), 2)) ) assign_SEQ(df, key_vars = c("USUBJID", "XXTESTCD"), seq_prefix = "XX")
Run the code above in your browser using DataLab