I attempted to parametrize the code a bit further, does this do what you are looking for if you change minT, maxT, stepT, ycol, grouping and use your table
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Rats.jmp");
minT = 100;
maxT = 350;
stepT = 50;
ycol = "days";
grouping = "Group";
Summarize(dt, groups = by(Eval(grouping)));
obj = dt << Survival(
Y(Eval(ycol)),
Censor(:Censor),
Grouping(Eval(grouping)),
Show Points(1),
SendToReport(
Dispatch({"Survival Plot"}, "1", ScaleBox,
{Min(minT), Max(maxT), Inc(stepT), Minor Ticks(1)}
),
)
);
rep = Report(obj);
rep[List Box(2)] << append(tb = Table Box(String Col Box("No at Risk ("||ycol||")", groups)));
rep[List Box(2)] << Append(Spacer Box(Size(0,20)));
tabs = {};
For Each({group}, groups,
Insert Into(tabs, Eval List({rep[OutlineBox(group), Table Box(1)] << get}));
);
For(T = minT, T <= maxT, T += stepT,
ARs = {};
For Each({tab}, tabs,
lp = Max(Loc(Matrix(tab[ycol]) <= T));
Insert Into(ARS, tab["At Risk"][lp])
);
tb << append(Number Col Box(Char(T), ARs));
);
I attempted to parametrize the code a bit further, does this do what you are looking for if you change minT, maxT, stepT, ycol, grouping and use your table
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Rats.jmp");
minT = 100;
maxT = 350;
stepT = 50;
ycol = "days";
grouping = "Group";
Summarize(dt, groups = by(Eval(grouping)));
obj = dt << Survival(
Y(Eval(ycol)),
Censor(:Censor),
Grouping(Eval(grouping)),
Show Points(1),
SendToReport(
Dispatch({"Survival Plot"}, "1", ScaleBox,
{Min(minT), Max(maxT), Inc(stepT), Minor Ticks(1)}
),
)
);
rep = Report(obj);
rep[List Box(2)] << append(tb = Table Box(String Col Box("No at Risk ("||ycol||")", groups)));
rep[List Box(2)] << Append(Spacer Box(Size(0,20)));
tabs = {};
For Each({group}, groups,
Insert Into(tabs, Eval List({rep[OutlineBox(group), Table Box(1)] << get}));
);
For(T = minT, T <= maxT, T += stepT,
ARs = {};
For Each({tab}, tabs,
lp = Max(Loc(Matrix(tab[ycol]) <= T));
Insert Into(ARS, tab["At Risk"][lp])
);
tb << append(Number Col Box(Char(T), ARs));
);
Here is also a script which can be used basically on Survivor report. It might work in most of the cases but not sure if it will as I'm not that familiar with this JMP Platform or analysis. I also modified the calculations so they might not be exactly correct
First you have to have Survivor report open
then you can run the script and it will ask for few things
Fill in those and press OK
It will then add the table to your existing report
Script below (and also attached). Use at your own risk, the calculations have not been checked
Thanks for this script! I really like it. When I generate multiple survival curves at once using the set up below ("Grouping" and "By" specified), the at risk table is only added to the first plot. Is there a way to have it added to all of them?
To QC the output, I just re-made a reference figure (see below JMP vs reference) and noticed a few details. Starting from the left, at time = 0, the number at risk, 40, is correct, however, subsequent timepoints are inflated by 1. The exception is when the true number is zero, which the script accurately lists. Lastly, there is a 1 at the last timepoint, which should not be there. I could fix this in Excel but would be amazing if there was a scripting fix!
Not sure which calculation is incorrect. If it is in my script, you can most likely fix it somewhere here
I would need example dataset with correct answers to know what the results should be (the interpolate option in my script doesn't seem to work correctly though).