According to https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/55338/high... , Could you please provide the method for generating a risk table underneath the KM plot? I tried to follow the script from the comment but it was closed to be solved.
dt = Current Data Table ();
minT = 0;
maxT = 25;
stepT = 1;
Summarize( lv = by( :group) );
obj = Survival(
Y( :time ),
Censor( :"reject"n ),
Grouping( :group ),
Failure Plot( 0 ),
SendToReport(
Dispatch(
{"Survival Plot"},
"1",
ScaleBox,
{Min( 0 ), Max( 25 ), Inc( 1 ), Minor Ticks( 1 )}
),
Dispatch(
{"Survival Plot"},
"time",
TextEditBox,
{Set Text( "Times(years)" )}
)
)
) << report;
obj[List Box( 2 )] << append( Table Box( String Col Box( "No at Risk | Year", lv ) ) );
Tab1 = (obj[lv[1]][Table Box( 1 )] << get);
Tab2 = (obj[lv[2]][Table Box( 1 )] << get);
For( T = minT, T <= maxT, T += stepT,
lp = Max( Loc( Matrix( Tab1 [years] ) <= T ) );
AR1 = Tab1["At Risk"][lp];
lp = Max( Loc( Matrix( Tab2 [years]) <= T ) );
AR2 = Tab2["At Risk"][lp];
obj[List Box( 2 )][Table Box( 1 )] << append( Number Col Box( Char( T ), {AR1, AR2} ) );
);
the out put showed as the attachment picture. Could you please to correct the script?
Thank you