Hello @jawla and welcome to the SAS Support Communities!
Please try this and check if it meets your expectations:
/* Create test data */
data have;
input Rx time censored;
cards;
0 2 0
0 4 0
0 4 0
0 7 0
0 7 0
0 7 0
0 8 0
0 8 1
0 8 1
0 9 1
1 1 0
1 1 0
1 2 0
1 3 0
1 6 0
1 7 0
1 8 1
1 8 1
;
/* Define format for Rx groups */
proc format;
value rxf
.c = 'combined';
run;
/* Count tied events */
proc sql;
create table want as
select Rx format=rxf., sum(d) as ties label='Tied events' from
(select Rx, time, count(time) as d from have
where censored=0
group by Rx, time
having d>1)
group by Rx
union
select .c as Rx, sum(d) as ties from
(select time, count(time) as d from have
where censored=0
group by time
having d>1)
order by missing(Rx), Rx;
quit;
proc print data=want noobs label;
run;
Result:
Tied
Rx events
0 5
1 2
combined 10
It is assumed that dataset HAVE has one observation per patient.
... View more