You're just missing length
:
data[, length(unique(list(x,y))), by = 'id']
# id V1
# 1: 22 1
# 2: 33 2
Regarding your question in the comment, this seems to work:
data[, length(unique(as.list(.SD))), by = "id", .SDcols = 2:3]
# id V1
# 1: 22 1
# 2: 33 2