Lee,
No need to trim starting or ending comma, neither to check if the filter is empty:
((lambda (/ f l)
(setq f "")
(while (setq l (tblnext "layer" (not l)))
(if (= 4 (logand 4 (cdr (assoc 70 l))))
(setq f (strcat f (cdr (assoc 2 l)) ","))
)
)
(ssget "_X" (list '(-4 . "<not") (cons 8 f) '(-4 . "not>")))
)
)