The special symbol .SD is available in j of DT[i,j,by], capturing the Subset of Data for each by group surviving the filter, i. .SDcols is a helper. Type ?`special-symbols`  for the official docs.   A reminder: DT[where, select|update|do, by] syntax is used to work with columns of a data.table.
T...