I have a dataset I'm doing survival analysis on using the COX PH model. I wanted to ask if there's a SAS code for generating the no. of tied events in a model, just like in the example blow in Red. I have searched extensively but haven't found anyway of generating using SAS code.
Percent
Stratum RX Total Failed Censored Censored
1 0 21 9 12 57.14
2 1 21 21 0 0.00
-------------------------------------------------------------------
Total 42 30 12 28.57
Tied events: For Rx=0, 3 patients
For Rx=1, 16
Tied events for both Rx groups combined: 23
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.
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.