Do you mean something like this?
DECLARE @Table TABLE (ID INT,HasCollected NVARCHAR(10),TimeCollect NVARCHAR(50))
INSERT @Table
VALUES
(1,'YES','Baseline'),
(1,'NO', '24 Hours'),
(1,'NO', '48 Hours'),
(2,'YES','Baseline'),
(2,'YES','24 Hours'),
(2,'NO', '48 Hours'),
(3,'NO', 'Baseline'),
(3,'YES','24 Hours'),
(3,'NO', '48 Hours'),
(4,'NO', 'Baseline'),
(4,'YES','24 Hours'),
(4,'YES','48 Hours')
SELECT TimeCollect, COUNT(*) NumIds
FROM(
SELECT DISTINCT
ID,
STUFF((SELECT ',' + t.TimeCollect
FROM @Table t
WHERE t.ID = t2.ID
AND t.HasCollected = 'YES'
FOR XML PATH('')), 1, 1,'') AS TimeCollect
FROM @Table t2
GROUP BY t2.ID
)a
GROUP BY TimeCollect
Results:
TimeCollect NumIds
24 Hours 1
24 Hours,48 Hours 1
Baseline 1
Baseline,24 Hours 1
Or if you have SQL Server 2017+:
SELECT TimeCollect, COUNT(*) NumIds
FROM(
SELECT ID,
STRING_AGG(TimeCollect,', ') AS TimeCollect
FROM @Table t
WHERE t.HasCollected = 'YES'
GROUP BY ID
)a
GROUP BY TimeCollect