<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Risk Table of KM plot on JMP? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844403#M101840</link>
    <description>&lt;P&gt;It should be possible but will require modifications to the script. You can try if this version works for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

ask_steps = function({}, {Default Local},
	nw = New Window("Fill in Time to Event Steps", &amp;lt;&amp;lt; Type("Modal Dialog"), &amp;lt;&amp;lt; Return Result,
		H List Box(
			Panel Box("Fill in steps",
				Lineup Box(N Col(2),
					Text Box("Min Time"),
					neb_min = Number Edit Box(.),
					Text Box("Max Time"),
					neb_max = Number Edit Box(.),
					Text Box("Step Time"),
					neb_step = Number Edit Box(.),
					Text Box("Interpolate last"),
					cb_interpolate = Check Box({""}, &amp;lt;&amp;lt; Set All(1))
				)
			),
			Spacer Box(Size(20, 0)),
			Panel Box("Actions",
				Button Box("OK"),
				Button Box("Cancel")
			)
		)
		, &amp;lt;&amp;lt; Set Window Icon("Survival")
	);
	
	If(nw["Button"] != 1,
		Throw("Cancelled");
	);
	
	min_t = nw["neb_min"];
	max_t = nw["neb_max"];
	step_t = nw["neb_step"];

	If(Any(Is Missing(min_t), Is Missing(max_t), Is Missing(step_t)),
		Throw("Steps not filled in");
	);
	
	interpolate_last = N Items(nw["cb_interpolate"]);

	return(Eval List({min_t, max_t, step_t, interpolate_last}));
);

add_risk_table = function({platform_ref, min_t, max_t, step_t, interpolate_last}, {Default Local},

	rep = Report(platform_ref);
	dt = platform_ref &amp;lt;&amp;lt; Get Data Table;
	
	ycol = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Time to event: ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	grouping_col = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Grouped by ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	Summarize(dt, groups = by(Eval(grouping_col)));

	steps = min_t::max_t::step_t;
	vals = steps;
	
	For Each({group}, groups,
		m_tb = rep[OutlineBox(group), Table Box(1)] &amp;lt;&amp;lt; get as matrix;
		
		times = m_tb[0, 1];
		atrisk = m_tb[0, N Cols(m_tb)];
		cur_steps = Step(steps, times, atrisk); // Last one isn't assumed in this
		
		If(interpolate_last,
			If(times[N Rows(times), 1] &amp;lt; max_t &amp;amp; Is Missing(cur_steps[N Cols(cur_steps)]),
				cur_steps[N Cols(cur_steps)] = atrisk[N Rows(times), 1];
			);			
		);
		vals = vals |/ cur_steps;
	);


	pb = Panel Box("Risk Table", tb_results = Table Box(
		String Col Box(Eval Insert("No at Risk (^ycol^)"), groups),
	));


	For(i = 1, i &amp;lt;= N Cols(vals), i++,
		cur_vals = vals[0, i];
		
		title = Char(Remove From(cur_vals, 1)[1]);
		
		tb_results &amp;lt;&amp;lt; Append(Number Col Box(title, cur_vals));
	);

	rep[List Box(2)] &amp;lt;&amp;lt; Append(pb);
	rep[List Box(2)] &amp;lt;&amp;lt; Append(Spacer Box(Size(0, 10)));
);



cur_rep = Current Report();
If(Is Empty(cur_rep),
	Throw("No reports open");
);

ob_refs = cur_rep &amp;lt;&amp;lt; XPath("//OutlineBox[@helpKey='Surv']");

If(N Items(ob_refs) == 0,
	Throw("No Surv platform found");
);

Try(
	{min_t, max_t, step_t, interpolate_last} = ask_steps();
	
	For Each({ob_ref}, ob_refs,
		platform_ref = ob_ref &amp;lt;&amp;lt; get scriptable object;

		add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);		
	);

,
	Throw("Other issues: " || char(exception_msg));
);


Write();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;There are only few changes I did to the end of script, I basically just added one for each loop (and changed one variable name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 18:39:25 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-02-26T18:39:25Z</dc:date>
    <item>
      <title>Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777716#M95918</link>
      <description>&lt;P&gt;According to&amp;nbsp;&lt;A title="Displaying at risk tables under kaplan meier" href="https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/55338/highlight/true#M31302" target="_blank" rel="noopener"&gt;https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/55338/highlight/true#M31302&lt;/A&gt;&amp;nbsp;, 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.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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)" )}
		)
	)
) &amp;lt;&amp;lt; report;
obj[List Box( 2 )] &amp;lt;&amp;lt; append( Table Box( String Col Box( "No at Risk | Year", lv ) ) );
Tab1 = (obj[lv[1]][Table Box( 1 )] &amp;lt;&amp;lt; get);
Tab2 = (obj[lv[2]][Table Box( 1 )] &amp;lt;&amp;lt; get);
For( T = minT, T &amp;lt;= maxT, T += stepT,
	lp = Max( Loc( Matrix( Tab1 [years] ) &amp;lt;= T ) );
	AR1 = Tab1["At Risk"][lp];
	lp = Max( Loc( Matrix( Tab2 [years]) &amp;lt;= T ) );
	AR2 = Tab2["At Risk"][lp];
	obj[List Box( 2 )][Table Box( 1 )] &amp;lt;&amp;lt; append( Number Col Box( Char( T ), {AR1, AR2} ) );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the out put showed as the attachment picture. Could you please to correct the script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 14:44:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777716#M95918</guid>
      <dc:creator>doraemengs</dc:creator>
      <dc:date>2024-07-31T14:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777727#M95919</link>
      <description>&lt;P&gt;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&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; 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)] &amp;lt;&amp;lt; append(tb = Table Box(String Col Box("No at Risk ("||ycol||")", groups)));
rep[List Box(2)] &amp;lt;&amp;lt; Append(Spacer Box(Size(0,20)));

tabs = {};
For Each({group}, groups,
	Insert Into(tabs, Eval List({rep[OutlineBox(group), Table Box(1)] &amp;lt;&amp;lt; get}));
);


For(T = minT, T &amp;lt;= maxT, T += stepT,
	
	ARs = {};
	For Each({tab}, tabs,
		lp = Max(Loc(Matrix(tab[ycol]) &amp;lt;= T));
		Insert Into(ARS, tab["At Risk"][lp])
	);
		
	tb &amp;lt;&amp;lt; append(Number Col Box(Char(T), ARs));
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit: small fixes&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 15:04:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777727#M95919</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-31T15:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777758#M95929</link>
      <description>&lt;P&gt;Hi Jarmo, Thank you for your help. It worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best, Theerachai&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 16:55:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777758#M95929</guid>
      <dc:creator>doraemengs</dc:creator>
      <dc:date>2024-07-31T16:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777774#M95931</link>
      <description>&lt;P&gt;Here is also a script which can be used basically on Survivor report. It might work in most of the cases but&amp;nbsp; 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&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you have to have Survivor report open&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1722445639973.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66675iAA63344DD8E032F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1722445639973.png" alt="jthi_1-1722445639973.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;then you can run the script and it will ask for few things&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1722445470437.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66674i2E34B119C45AA7AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1722445470437.png" alt="jthi_0-1722445470437.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Fill in those and press OK&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1722445724506.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66676i5A403C01C7780BEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1722445724506.png" alt="jthi_2-1722445724506.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It will then add the table to your existing report&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_3-1722445739773.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66677i64CDEACA9D82BC26/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_3-1722445739773.png" alt="jthi_3-1722445739773.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script below (and also attached). &lt;STRONG&gt;Use at your own risk, the calculations have not been checked&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*""" Add risk table to Survival platform

Author: jthi
Creation Date: 2024-07-31
Creation JMP Version: JMP Pro 18.0.1

Description: Based on
	https://community.jmp.com/t5/Discussions/Displaying-at-risk-tables-under-kaplan-meier/m-p/305898/highlight/true#M56162

Todo:
    * Show steps to user before pressing OK
    * Remove modal window
    * Turn into add-in / proper script
    * Add instructions / title to UI
    * Add utility modal
	
"""*/

Names Default To Here(1);

ask_steps = function({}, {Default Local},
	nw = New Window("Fill in Time to Event Steps", &amp;lt;&amp;lt; Type("Modal Dialog"), &amp;lt;&amp;lt; Return Result,
		H List Box(
			Panel Box("Fill in steps",
				Lineup Box(N Col(2),
					Text Box("Min Time"),
					neb_min = Number Edit Box(.),
					Text Box("Max Time"),
					neb_max = Number Edit Box(.),
					Text Box("Step Time"),
					neb_step = Number Edit Box(.),
					Text Box("Interpolate last"),
					cb_interpolate = Check Box({""}, &amp;lt;&amp;lt; Set All(1))
				)
			),
			Spacer Box(Size(20, 0)),
			Panel Box("Actions",
				Button Box("OK"),
				Button Box("Cancel")
			)
		)
		, &amp;lt;&amp;lt; Set Window Icon("Survival")
	);
	
	If(nw["Button"] != 1,
		Throw("Cancelled");
	);
	
	min_t = nw["neb_min"];
	max_t = nw["neb_max"];
	step_t = nw["neb_step"];

	If(Any(Is Missing(min_t), Is Missing(max_t), Is Missing(step_t)),
		Throw("Steps not filled in");
	);
	
	interpolate_last = N Items(nw["cb_interpolate"]);

	return(Eval List({min_t, max_t, step_t, interpolate_last}));
);

add_risk_table = function({platform_ref, min_t, max_t, step_t, interpolate_last}, {Default Local},

	rep = Report(platform_ref);
	dt = platform_ref &amp;lt;&amp;lt; Get Data Table;
	
	ycol = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Time to event: ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	grouping_col = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Grouped by ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	Summarize(dt, groups = by(Eval(grouping_col)));

	steps = min_t::max_t::step_t;
	vals = steps;
	
	For Each({group}, groups,
		m_tb = rep[OutlineBox(group), Table Box(1)] &amp;lt;&amp;lt; get as matrix;
		
		times = m_tb[0, 1];
		atrisk = m_tb[0, N Cols(m_tb)];
		cur_steps = Step(steps, times, atrisk); // Last one isn't assumed in this
		
		If(interpolate_last,
			If(times[N Rows(times), 1] &amp;lt; max_t &amp;amp; Is Missing(cur_steps[N Cols(cur_steps)]),
				cur_steps[N Cols(cur_steps)] = atrisk[N Rows(times), 1];
			);			
		);
		vals = vals |/ cur_steps;
	);


	pb = Panel Box("Risk Table", tb_results = Table Box(
		String Col Box(Eval Insert("No at Risk (^ycol^)"), groups),
	));


	For(i = 1, i &amp;lt;= N Cols(vals), i++,
		cur_vals = vals[0, i];
		
		title = Char(Remove From(cur_vals, 1)[1]);
		
		tb_results &amp;lt;&amp;lt; Append(Number Col Box(title, cur_vals));
	);

	rep[List Box(2)] &amp;lt;&amp;lt; Append(pb);
	rep[List Box(2)] &amp;lt;&amp;lt; Append(Spacer Box(Size(0, 10)));
);



cur_rep = Current Report();
If(Is Empty(cur_rep),
	Throw("No reports open");
);

ob_ref = cur_rep &amp;lt;&amp;lt; XPath("//OutlineBox[@helpKey='Surv']");

If(N Items(ob_ref) == 0,
	Throw("No Surv platform found");
);

Try(
	{min_t, max_t, step_t, interpolate_last} = ask_steps();

	platform_ref = ob_ref[1] &amp;lt;&amp;lt; get scriptable object;

	add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);
,
	Throw("Other issues: " || char(exception_msg));
);


Write();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 17:18:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/777774#M95931</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-31T17:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844400#M101839</link>
      <description>&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PanelWildcat806_0-1740534582505.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73346iB83E8C150FEFDBC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PanelWildcat806_0-1740534582505.png" alt="PanelWildcat806_0-1740534582505.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 01:56:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844400#M101839</guid>
      <dc:creator>PanelWildcat806</dc:creator>
      <dc:date>2025-02-26T01:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844403#M101840</link>
      <description>&lt;P&gt;It should be possible but will require modifications to the script. You can try if this version works for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

ask_steps = function({}, {Default Local},
	nw = New Window("Fill in Time to Event Steps", &amp;lt;&amp;lt; Type("Modal Dialog"), &amp;lt;&amp;lt; Return Result,
		H List Box(
			Panel Box("Fill in steps",
				Lineup Box(N Col(2),
					Text Box("Min Time"),
					neb_min = Number Edit Box(.),
					Text Box("Max Time"),
					neb_max = Number Edit Box(.),
					Text Box("Step Time"),
					neb_step = Number Edit Box(.),
					Text Box("Interpolate last"),
					cb_interpolate = Check Box({""}, &amp;lt;&amp;lt; Set All(1))
				)
			),
			Spacer Box(Size(20, 0)),
			Panel Box("Actions",
				Button Box("OK"),
				Button Box("Cancel")
			)
		)
		, &amp;lt;&amp;lt; Set Window Icon("Survival")
	);
	
	If(nw["Button"] != 1,
		Throw("Cancelled");
	);
	
	min_t = nw["neb_min"];
	max_t = nw["neb_max"];
	step_t = nw["neb_step"];

	If(Any(Is Missing(min_t), Is Missing(max_t), Is Missing(step_t)),
		Throw("Steps not filled in");
	);
	
	interpolate_last = N Items(nw["cb_interpolate"]);

	return(Eval List({min_t, max_t, step_t, interpolate_last}));
);

add_risk_table = function({platform_ref, min_t, max_t, step_t, interpolate_last}, {Default Local},

	rep = Report(platform_ref);
	dt = platform_ref &amp;lt;&amp;lt; Get Data Table;
	
	ycol = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Time to event: ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	grouping_col = ((rep &amp;lt;&amp;lt; XPath("//TextBox[text()='Grouped by ']"))[1] &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get text;
	Summarize(dt, groups = by(Eval(grouping_col)));

	steps = min_t::max_t::step_t;
	vals = steps;
	
	For Each({group}, groups,
		m_tb = rep[OutlineBox(group), Table Box(1)] &amp;lt;&amp;lt; get as matrix;
		
		times = m_tb[0, 1];
		atrisk = m_tb[0, N Cols(m_tb)];
		cur_steps = Step(steps, times, atrisk); // Last one isn't assumed in this
		
		If(interpolate_last,
			If(times[N Rows(times), 1] &amp;lt; max_t &amp;amp; Is Missing(cur_steps[N Cols(cur_steps)]),
				cur_steps[N Cols(cur_steps)] = atrisk[N Rows(times), 1];
			);			
		);
		vals = vals |/ cur_steps;
	);


	pb = Panel Box("Risk Table", tb_results = Table Box(
		String Col Box(Eval Insert("No at Risk (^ycol^)"), groups),
	));


	For(i = 1, i &amp;lt;= N Cols(vals), i++,
		cur_vals = vals[0, i];
		
		title = Char(Remove From(cur_vals, 1)[1]);
		
		tb_results &amp;lt;&amp;lt; Append(Number Col Box(title, cur_vals));
	);

	rep[List Box(2)] &amp;lt;&amp;lt; Append(pb);
	rep[List Box(2)] &amp;lt;&amp;lt; Append(Spacer Box(Size(0, 10)));
);



cur_rep = Current Report();
If(Is Empty(cur_rep),
	Throw("No reports open");
);

ob_refs = cur_rep &amp;lt;&amp;lt; XPath("//OutlineBox[@helpKey='Surv']");

If(N Items(ob_refs) == 0,
	Throw("No Surv platform found");
);

Try(
	{min_t, max_t, step_t, interpolate_last} = ask_steps();
	
	For Each({ob_ref}, ob_refs,
		platform_ref = ob_ref &amp;lt;&amp;lt; get scriptable object;

		add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);		
	);

,
	Throw("Other issues: " || char(exception_msg));
);


Write();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;There are only few changes I did to the end of script, I basically just added one for each loop (and changed one variable name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:39:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844403#M101840</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-26T18:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844582#M101875</link>
      <description>&lt;P&gt;Thanks for the quick reply! I am getting this message though?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PanelWildcat806_0-1740594852451.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73366i537B073A8C654CB7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PanelWildcat806_0-1740594852451.png" alt="PanelWildcat806_0-1740594852451.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:34:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844582#M101875</guid>
      <dc:creator>PanelWildcat806</dc:creator>
      <dc:date>2025-02-26T18:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844586#M101877</link>
      <description>&lt;P&gt;One s is missing&amp;nbsp; from line 100&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1740595131358.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73368iCB50CBACDFE1B63F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1740595131358.png" alt="jthi_0-1740595131358.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I edited my earlier post to fix the issue&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 18:39:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844586#M101877</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-26T18:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844608#M101887</link>
      <description>&lt;P&gt;Thank you again! It works now!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PanelWildcat806_2-1740600954048.png" style="width: 900px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73378i4C80D16B89F2C940/image-dimensions/900x72?v=v2" width="900" height="72" role="button" title="PanelWildcat806_2-1740600954048.png" alt="PanelWildcat806_2-1740600954048.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 20:21:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844608#M101887</guid>
      <dc:creator>PanelWildcat806</dc:creator>
      <dc:date>2025-02-26T20:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844691#M101894</link>
      <description>&lt;P&gt;Not sure which calculation is incorrect. If it is in my script, you can most likely fix it somewhere here&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1740633522054.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73382i60D84C4F17996960/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1740633522054.png" alt="jthi_0-1740633522054.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;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).&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 05:36:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/844691#M101894</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-02-27T05:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/888072#M105026</link>
      <description>&lt;P&gt;following up on the "inflated" at risk number.&amp;nbsp; Using your script (thanks!) on the VP Lung cancer dataset, I get 1 additional at risk numbers for 400 for the standard group and 200, 400, 600, 800 for test test group.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jkarcusbiojmpco_0-1752869954880.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78557i91F24C3252E20922/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jkarcusbiojmpco_0-1752869954880.png" alt="jkarcusbiojmpco_0-1752869954880.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;looking at the data table, values with exact timepoint (200 for standard - first pink row) shows correct at risk number, however for when there is not an exact match, such as 400, 600 and 800) current script is brining in the number before the specified time point. it would be great if scripting can fix these cases.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jkarcusbiojmpco_1-1752870291733.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78558i8BA8453120D89F3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jkarcusbiojmpco_1-1752870291733.png" alt="jkarcusbiojmpco_1-1752870291733.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jkarcusbiojmpco_2-1752870542512.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/78559i857808ECC433A27E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jkarcusbiojmpco_2-1752870542512.png" alt="jkarcusbiojmpco_2-1752870542512.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jul 2025 20:35:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/888072#M105026</guid>
      <dc:creator>jkarcusbiojmpco</dc:creator>
      <dc:date>2025-07-18T20:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Risk Table of KM plot on JMP?</title>
      <link>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/888364#M105067</link>
      <description>&lt;P&gt;What it should display if not the earlier value?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 18:49:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Risk-Table-of-KM-plot-on-JMP/m-p/888364#M105067</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-07-21T18:49:38Z</dc:date>
    </item>
  </channel>
</rss>

