cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
%3CLINGO-SUB%20id%3D%22lingo-sub-777716%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EJMP%EC%9D%98%20KM%20%ED%94%8C%EB%A1%AF%20%EC%9C%84%ED%97%98%ED%91%9C%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777716%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20title%3D%22Kaplan%20meier%20%EC%95%84%EB%9E%98%20%EC%9C%84%ED%97%98%20%ED%85%8C%EC%9D%B4%EB%B8%94%20%ED%91%9C%EC%8B%9C%22%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying-at-risk-tables-under-kaplan-meier%2Fm-p%2F55338%2Fhighlight%2Ftrue%23M31302%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying-at-risk-tables-under-kaplan-meier%2Fmp%2F55338%2Fhighlight%2Ftrue%23M31302%3C%2FA%3E%20%EC%97%90%20%EB%94%B0%EB%A5%B4%EB%A9%B4%20%EC%9C%84%ED%97%98%EC%9D%84%20%EC%83%9D%EC%84%B1%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%84%20%EC%A0%9C%EA%B3%B5%ED%95%B4%20%EC%A3%BC%EC%8B%9C%EA%B2%A0%EC%8A%B5%EB%8B%88%EA%B9%8C%3F%20KM%20%ED%94%8C%EB%A1%AF%20%EC%95%84%EB%9E%98%EC%97%90%20%ED%85%8C%EC%9D%B4%EB%B8%94%EC%9D%B4%20%EC%9E%88%EC%8A%B5%EB%8B%88%EA%B9%8C%3F%20%EB%8C%93%EA%B8%80%EC%97%90%EC%84%9C%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EB%94%B0%EB%9D%BC%ED%95%B4%EB%B3%B4%EB%A0%A4%EA%B3%A0%20%ED%96%88%EB%8A%94%EB%8D%B0%20%ED%95%B4%EA%B2%B0%EC%9D%B4%20%EC%95%88%EB%90%98%EC%84%9C%20%EB%8B%AB%ED%98%80%EB%B2%84%EB%A0%B8%EB%84%A4%EC%9A%94.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Current%20Data%20Table%20()%3B%0AminT%20%3D%200%3B%0AmaxT%20%3D%2025%3B%0AstepT%20%3D%201%3B%0A%0ASummarize(%20lv%20%3D%20by(%20%3Agroup)%20)%3B%0Aobj%20%3D%20Survival(%0A%09Y(%20%3Atime%20)%2C%0A%09Censor(%20%3A%22reject%22n%20)%2C%0A%09Grouping(%20%3Agroup%20)%2C%0A%09Failure%20Plot(%200%20)%2C%0A%09SendToReport(%0A%09%09Dispatch(%0A%09%09%09%7B%22Survival%20Plot%22%7D%2C%0A%09%09%09%221%22%2C%0A%09%09%09ScaleBox%2C%0A%09%09%09%7BMin(%200%20)%2C%20Max(%2025%20)%2C%20Inc(%201%20)%2C%20Minor%20Ticks(%201%20)%7D%0A%09%09)%2C%0A%09%09Dispatch(%0A%09%09%09%7B%22Survival%20Plot%22%7D%2C%0A%09%09%09%22time%22%2C%0A%09%09%09TextEditBox%2C%0A%09%09%09%7BSet%20Text(%20%22Times(years)%22%20)%7D%0A%09%09)%0A%09)%0A)%20%26lt%3B%26lt%3B%20report%3B%0Aobj%5BList%20Box(%202%20)%5D%20%26lt%3B%26lt%3B%20append(%20Table%20Box(%20String%20Col%20Box(%20%22No%20at%20Risk%20%7C%20Year%22%2C%20lv%20)%20)%20)%3B%0ATab1%20%3D%20(obj%5Blv%5B1%5D%5D%5BTable%20Box(%201%20)%5D%20%26lt%3B%26lt%3B%20get)%3B%0ATab2%20%3D%20(obj%5Blv%5B2%5D%5D%5BTable%20Box(%201%20)%5D%20%26lt%3B%26lt%3B%20get)%3B%0AFor(%20T%20%3D%20minT%2C%20T%20%26lt%3B%3D%20maxT%2C%20T%20%2B%3D%20stepT%2C%0A%09lp%20%3D%20Max(%20Loc(%20Matrix(%20Tab1%20%5Byears%5D%20)%20%26lt%3B%3D%20T%20)%20)%3B%0A%09AR1%20%3D%20Tab1%5B%22At%20Risk%22%5D%5Blp%5D%3B%0A%09lp%20%3D%20Max(%20Loc(%20Matrix(%20Tab2%20%5Byears%5D)%20%26lt%3B%3D%20T%20)%20)%3B%0A%09AR2%20%3D%20Tab2%5B%22At%20Risk%22%5D%5Blp%5D%3B%0A%09obj%5BList%20Box(%202%20)%5D%5BTable%20Box(%201%20)%5D%20%26lt%3B%26lt%3B%20append(%20Number%20Col%20Box(%20Char(%20T%20)%2C%20%7BAR1%2C%20AR2%7D%20)%20)%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%EC%B6%9C%EB%A0%A5%EC%9D%80%20%EC%B2%A8%EB%B6%80%20%EC%82%AC%EC%A7%84%EC%9C%BC%EB%A1%9C%20%EB%B3%B4%EC%97%AC%EC%A3%BC%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%88%98%EC%A0%95%ED%95%B4%20%EC%A3%BC%EC%8B%9C%EA%B2%A0%EC%96%B4%EC%9A%94%3F%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%EA%B0%90%EC%82%AC%ED%95%A9%EB%8B%88%EB%8B%A4%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-777716%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%EB%8D%B0%EC%9D%B4%ED%84%B0%20%ED%83%90%EC%83%89%20%EB%B0%8F%20%EC%8B%9C%EA%B0%81%ED%99%94%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20JMP%EC%9D%98%20KM%20%ED%94%8C%EB%A1%AF%20%EC%9C%84%ED%97%98%ED%91%9C%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%EC%BD%94%EB%93%9C%EB%A5%BC%20%EC%A2%80%20%EB%8D%94%20%EB%A7%A4%EA%B0%9C%EB%B3%80%EC%88%98%ED%99%94%ED%95%98%EB%A0%A4%EA%B3%A0%20%ED%96%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20minT%2C%20maxT%2C%20stepT%2C%20ycol%2C%20%EA%B7%B8%EB%A3%B9%ED%99%94%EB%A5%BC%20%EB%B3%80%EA%B2%BD%ED%95%98%EA%B3%A0%20%ED%85%8C%EC%9D%B4%EB%B8%94%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EA%B2%BD%EC%9A%B0%20%EC%9B%90%ED%95%98%EB%8A%94%20%EC%9E%91%EC%97%85%EC%9D%84%20%EC%88%98%ED%96%89%ED%95%A9%EB%8B%88%EA%B9%8C%3F%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20Open(%22%24SAMPLE_DATA%2FRats.jmp%22)%3B%0A%0AminT%20%3D%20100%3B%0AmaxT%20%3D%20350%3B%0AstepT%20%3D%2050%3B%0Aycol%20%3D%20%22days%22%3B%0Agrouping%20%3D%20%22Group%22%3B%0A%0ASummarize(dt%2C%20groups%20%3D%20by(Eval(grouping)))%3B%0A%0Aobj%20%3D%20dt%20%26lt%3B%26lt%3B%20Survival(%0A%09Y(Eval(ycol))%2C%0A%09Censor(%3ACensor)%2C%0A%09Grouping(Eval(grouping))%2C%0A%09Show%20Points(1)%2C%0A%09SendToReport(%0A%09%09Dispatch(%7B%22Survival%20Plot%22%7D%2C%20%221%22%2C%20ScaleBox%2C%0A%09%09%09%7BMin(minT)%2C%20Max(maxT)%2C%20Inc(stepT)%2C%20Minor%20Ticks(1)%7D%0A%09%09)%2C%0A%0A%09)%0A)%3B%0A%0Arep%20%3D%20Report(obj)%3B%0A%0Arep%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20append(tb%20%3D%20Table%20Box(String%20Col%20Box(%22No%20at%20Risk%20(%22%7C%7Cycol%7C%7C%22)%22%2C%20groups)))%3B%0Arep%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20Append(Spacer%20Box(Size(0%2C20)))%3B%0A%0Atabs%20%3D%20%7B%7D%3B%0AFor%20Each(%7Bgroup%7D%2C%20groups%2C%0A%09Insert%20Into(tabs%2C%20Eval%20List(%7Brep%5BOutlineBox(group)%2C%20Table%20Box(1)%5D%20%26lt%3B%26lt%3B%20get%7D))%3B%0A)%3B%0A%0A%0AFor(T%20%3D%20minT%2C%20T%20%26lt%3B%3D%20maxT%2C%20T%20%2B%3D%20stepT%2C%0A%09%0A%09ARs%20%3D%20%7B%7D%3B%0A%09For%20Each(%7Btab%7D%2C%20tabs%2C%0A%09%09lp%20%3D%20Max(Loc(Matrix(tab%5Bycol%5D)%20%26lt%3B%3D%20T))%3B%0A%09%09Insert%20Into(ARS%2C%20tab%5B%22At%20Risk%22%5D%5Blp%5D)%0A%09)%3B%0A%09%09%0A%09tb%20%26lt%3B%26lt%3B%20append(Number%20Col%20Box(Char(T)%2C%20ARs))%3B%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%ED%8E%B8%EC%A7%91%3A%20%EC%9E%91%EC%9D%80%20%EC%88%98%EC%A0%95%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777758%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20JMP%EC%9D%98%20KM%20%ED%94%8C%EB%A1%AF%20%EC%9C%84%ED%97%98%ED%91%9C%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777758%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94%20Jarmo%2C%20%EB%8F%84%EC%9B%80%EC%9D%84%20%EC%A3%BC%EC%85%94%EC%84%9C%20%EA%B0%90%EC%82%AC%ED%95%A9%EB%8B%88%EB%8B%A4.%20%ED%9A%A8%EA%B3%BC%EA%B0%80%20%EC%9E%88%EC%97%88%EC%96%B4%EC%9A%94!%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%EC%B5%9C%EA%B3%A0%2C%20%ED%85%8C%EB%9D%BC%EC%B0%A8%EC%9D%B4%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-777774%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20JMP%EC%9D%98%20KM%20%ED%94%8C%EB%A1%AF%20%EC%9C%84%ED%97%98%ED%91%9C%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-777774%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%EC%83%9D%EC%A1%B4%EC%9E%90%20%EB%B3%B4%EA%B3%A0%EC%84%9C%EC%97%90%20%EA%B8%B0%EB%B3%B8%EC%A0%81%EC%9C%BC%EB%A1%9C%20%EC%82%AC%EC%9A%A9%ED%95%A0%20%EC%88%98%20%EC%9E%88%EB%8A%94%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%8F%84%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%8C%80%EB%B6%80%EB%B6%84%EC%9D%98%20%EA%B2%BD%EC%9A%B0%EC%97%90%20%EC%9E%91%EB%8F%99%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%A7%80%EB%A7%8C%20%EC%A0%80%EB%8A%94%20%EC%9D%B4%20JMP%20%ED%94%8C%EB%9E%AB%ED%8F%BC%EC%9D%B4%EB%82%98%20%EB%B6%84%EC%84%9D%EC%97%90%20%EC%9D%B5%EC%88%99%ED%95%98%EC%A7%80%20%EC%95%8A%EA%B8%B0%20%EB%95%8C%EB%AC%B8%EC%97%90%20%EC%9E%91%EB%8F%99%ED%95%A0%EC%A7%80%EB%8A%94%20%ED%99%95%EC%8B%A4%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EB%98%90%ED%95%9C%20%EA%B3%84%EC%82%B0%EC%9D%84%20%EC%88%98%EC%A0%95%ED%95%98%EC%97%AC%20%EC%A0%95%ED%99%95%ED%95%98%EC%A7%80%20%EC%95%8A%EC%9D%84%20%EC%88%98%EB%8F%84%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%EB%A8%BC%EC%A0%80%20%EC%83%9D%EC%A1%B4%EC%9E%90%20%EB%B3%B4%EA%B3%A0%EC%84%9C%EB%A5%BC%20%EC%97%B4%EC%96%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_1-1722445639973.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_1-1722445639973.png%22%20style%3D%22width%3A%20220px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66675iAA63344DD8E032F5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_1-1722445639973.png%22%20alt%3D%22jthi_1-1722445639973.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%EA%B7%B8%EB%9F%B0%20%EB%8B%A4%EC%9D%8C%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EC%8B%A4%ED%96%89%ED%95%98%EB%A9%B4%20%EB%AA%87%20%EA%B0%80%EC%A7%80%20%EC%82%AC%ED%95%AD%EC%9D%84%20%EB%AC%BB%EB%8A%94%20%EB%A9%94%EC%8B%9C%EC%A7%80%EA%B0%80%20%ED%91%9C%EC%8B%9C%EB%90%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1722445470437.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1722445470437.png%22%20style%3D%22width%3A%20344px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66674i2E34B119C45AA7AB%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_0-1722445470437.png%22%20alt%3D%22jthi_0-1722445470437.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%EB%82%B4%EC%9A%A9%EC%9D%84%20%EC%9E%85%EB%A0%A5%ED%95%98%EA%B3%A0%20%ED%99%95%EC%9D%B8%EC%9D%84%20%EB%88%84%EB%A5%B4%EC%84%B8%EC%9A%94.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_2-1722445724506.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_2-1722445724506.png%22%20style%3D%22width%3A%20344px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66676i5A403C01C7780BEA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_2-1722445724506.png%22%20alt%3D%22jthi_2-1722445724506.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%EA%B7%B8%EB%9F%B0%20%EB%8B%A4%EC%9D%8C%20%EA%B8%B0%EC%A1%B4%20%EB%B3%B4%EA%B3%A0%EC%84%9C%EC%97%90%20%ED%91%9C%EB%A5%BC%20%EC%B6%94%EA%B0%80%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_3-1722445739773.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_3-1722445739773.png%22%20style%3D%22width%3A%20211px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66677i64CDEACA9D82BC26%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_3-1722445739773.png%22%20alt%3D%22jthi_3-1722445739773.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%EC%95%84%EB%9E%98%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8(%EB%98%90%ED%95%9C%20%EC%B2%A8%EB%B6%80%EB%90%A8).%20%3CSTRONG%3E%EC%82%AC%EC%9A%A9%EC%97%90%20%EB%94%B0%EB%A5%B8%20%EC%B1%85%EC%9E%84%EC%9D%80%20%EB%B3%B8%EC%9D%B8%EC%97%90%EA%B2%8C%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%20%EA%B3%84%EC%82%B0%EC%9D%80%20%ED%99%95%EC%9D%B8%EB%90%98%EC%A7%80%20%EC%95%8A%EC%95%98%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CDIV%20class%3D%22lia-spoiler-container%22%3E%3CA%20class%3D%22lia-spoiler-link%22%20href%3D%22%23%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3E%EB%8D%94%EB%B3%B4%EA%B8%B0...%3C%2FA%3E%3CNOSCRIPT%3E(%EC%9D%BD%EC%9D%84%20%ED%95%98%EC%9D%B4%EB%9D%BC%EC%9D%B4%ED%8A%B8)%3C%2FNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-border%22%3E%3CDIV%20class%3D%22lia-spoiler-content%22%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F*%22%22%22%20Add%20risk%20table%20to%20Survival%20platform%0A%0AAuthor%3A%20jthi%0ACreation%20Date%3A%202024-07-31%0ACreation%20JMP%20Version%3A%20JMP%20Pro%2018.0.1%0A%0ADescription%3A%20Based%20on%0A%09https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying-at-risk-tables-under-kaplan-meier%2Fm-p%2F305898%2Fhighlight%2Ftrue%23M56162%0A%0ATodo%3A%0A%20%20%20%20*%20Show%20steps%20to%20user%20before%20pressing%20OK%0A%20%20%20%20*%20Remove%20modal%20window%0A%20%20%20%20*%20Turn%20into%20add-in%20%2F%20proper%20script%0A%20%20%20%20*%20Add%20instructions%20%2F%20title%20to%20UI%0A%20%20%20%20*%20Add%20utility%20modal%0A%09%0A%22%22%22*%2F%0A%0ANames%20Default%20To%20Here(1)%3B%0A%0Aask_steps%20%3D%20function(%7B%7D%2C%20%7BDefault%20Local%7D%2C%0A%09nw%20%3D%20New%20Window(%22Fill%20in%20Time%20to%20Event%20Steps%22%2C%20%26lt%3B%26lt%3B%20Type(%22Modal%20Dialog%22)%2C%20%26lt%3B%26lt%3B%20Return%20Result%2C%0A%09%09H%20List%20Box(%0A%09%09%09Panel%20Box(%22Fill%20in%20steps%22%2C%0A%09%09%09%09Lineup%20Box(N%20Col(2)%2C%0A%09%09%09%09%09Text%20Box(%22Min%20Time%22)%2C%0A%09%09%09%09%09neb_min%20%3D%20Number%20Edit%20Box(.)%2C%0A%09%09%09%09%09Text%20Box(%22Max%20Time%22)%2C%0A%09%09%09%09%09neb_max%20%3D%20Number%20Edit%20Box(.)%2C%0A%09%09%09%09%09Text%20Box(%22Step%20Time%22)%2C%0A%09%09%09%09%09neb_step%20%3D%20Number%20Edit%20Box(.)%2C%0A%09%09%09%09%09Text%20Box(%22Interpolate%20last%22)%2C%0A%09%09%09%09%09cb_interpolate%20%3D%20Check%20Box(%7B%22%22%7D%2C%20%26lt%3B%26lt%3B%20Set%20All(1))%0A%09%09%09%09)%0A%09%09%09)%2C%0A%09%09%09Spacer%20Box(Size(20%2C%200))%2C%0A%09%09%09Panel%20Box(%22Actions%22%2C%0A%09%09%09%09Button%20Box(%22OK%22)%2C%0A%09%09%09%09Button%20Box(%22Cancel%22)%0A%09%09%09)%0A%09%09)%0A%09%09%2C%20%26lt%3B%26lt%3B%20Set%20Window%20Icon(%22Survival%22)%0A%09)%3B%0A%09%0A%09If(nw%5B%22Button%22%5D%20!%3D%201%2C%0A%09%09Throw(%22Cancelled%22)%3B%0A%09)%3B%0A%09%0A%09min_t%20%3D%20nw%5B%22neb_min%22%5D%3B%0A%09max_t%20%3D%20nw%5B%22neb_max%22%5D%3B%0A%09step_t%20%3D%20nw%5B%22neb_step%22%5D%3B%0A%0A%09If(Any(Is%20Missing(min_t)%2C%20Is%20Missing(max_t)%2C%20Is%20Missing(step_t))%2C%0A%09%09Throw(%22Steps%20not%20filled%20in%22)%3B%0A%09)%3B%0A%09%0A%09interpolate_last%20%3D%20N%20Items(nw%5B%22cb_interpolate%22%5D)%3B%0A%0A%09return(Eval%20List(%7Bmin_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D))%3B%0A)%3B%0A%0Aadd_risk_table%20%3D%20function(%7Bplatform_ref%2C%20min_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D%2C%20%7BDefault%20Local%7D%2C%0A%0A%09rep%20%3D%20Report(platform_ref)%3B%0A%09dt%20%3D%20platform_ref%20%26lt%3B%26lt%3B%20Get%20Data%20Table%3B%0A%09%0A%09ycol%20%3D%20((rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FTextBox%5Btext()%3D'Time%20to%20event%3A%20'%5D%22))%5B1%5D%20%26lt%3B%26lt%3B%20sib)%20%26lt%3B%26lt%3B%20get%20text%3B%0A%09grouping_col%20%3D%20((rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FTextBox%5Btext()%3D'Grouped%20by%20'%5D%22))%5B1%5D%20%26lt%3B%26lt%3B%20sib)%20%26lt%3B%26lt%3B%20get%20text%3B%0A%09Summarize(dt%2C%20groups%20%3D%20by(Eval(grouping_col)))%3B%0A%0A%09steps%20%3D%20min_t%3A%3Amax_t%3A%3Astep_t%3B%0A%09vals%20%3D%20steps%3B%0A%09%0A%09For%20Each(%7Bgroup%7D%2C%20groups%2C%0A%09%09m_tb%20%3D%20rep%5BOutlineBox(group)%2C%20Table%20Box(1)%5D%20%26lt%3B%26lt%3B%20get%20as%20matrix%3B%0A%09%09%0A%09%09times%20%3D%20m_tb%5B0%2C%201%5D%3B%0A%09%09atrisk%20%3D%20m_tb%5B0%2C%20N%20Cols(m_tb)%5D%3B%0A%09%09cur_steps%20%3D%20Step(steps%2C%20times%2C%20atrisk)%3B%20%2F%2F%20Last%20one%20isn't%20assumed%20in%20this%0A%09%09%0A%09%09If(interpolate_last%2C%0A%09%09%09If(times%5BN%20Rows(times)%2C%201%5D%20%26lt%3B%20max_t%20%26amp%3B%20Is%20Missing(cur_steps%5BN%20Cols(cur_steps)%5D)%2C%0A%09%09%09%09cur_steps%5BN%20Cols(cur_steps)%5D%20%3D%20atrisk%5BN%20Rows(times)%2C%201%5D%3B%0A%09%09%09)%3B%09%09%09%0A%09%09)%3B%0A%09%09vals%20%3D%20vals%20%7C%2F%20cur_steps%3B%0A%09)%3B%0A%0A%0A%09pb%20%3D%20Panel%20Box(%22Risk%20Table%22%2C%20tb_results%20%3D%20Table%20Box(%0A%09%09String%20Col%20Box(Eval%20Insert(%22No%20at%20Risk%20(%5Eycol%5E)%22)%2C%20groups)%2C%0A%09))%3B%0A%0A%0A%09For(i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Cols(vals)%2C%20i%2B%2B%2C%0A%09%09cur_vals%20%3D%20vals%5B0%2C%20i%5D%3B%0A%09%09%0A%09%09title%20%3D%20Char(Remove%20From(cur_vals%2C%201)%5B1%5D)%3B%0A%09%09%0A%09%09tb_results%20%26lt%3B%26lt%3B%20Append(Number%20Col%20Box(title%2C%20cur_vals))%3B%0A%09)%3B%0A%0A%09rep%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20Append(pb)%3B%0A%09rep%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20Append(Spacer%20Box(Size(0%2C%2010)))%3B%0A)%3B%0A%0A%0A%0Acur_rep%20%3D%20Current%20Report()%3B%0AIf(Is%20Empty(cur_rep)%2C%0A%09Throw(%22No%20reports%20open%22)%3B%0A)%3B%0A%0Aob_ref%20%3D%20cur_rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FOutlineBox%5B%40helpKey%3D'Surv'%5D%22)%3B%0A%0AIf(N%20Items(ob_ref)%20%3D%3D%200%2C%0A%09Throw(%22No%20Surv%20platform%20found%22)%3B%0A)%3B%0A%0ATry(%0A%09%7Bmin_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D%20%3D%20ask_steps()%3B%0A%0A%09platform_ref%20%3D%20ob_ref%5B1%5D%20%26lt%3B%26lt%3B%20get%20scriptable%20object%3B%0A%0A%09add_risk_table(platform_ref%2C%20min_t%2C%20max_t%2C%20step_t%2C%20interpolate_last)%3B%0A%2C%0A%09Throw(%22Other%20issues%3A%20%22%20%7C%7C%20char(exception_msg))%3B%0A)%3B%0A%0A%0AWrite()%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%3CNOSCRIPT%3E%3CDIV%20class%3D%22lia-spoiler-noscript-container%22%3E%3CDIV%20class%3D%22lia-spoiler-noscript-content%22%3E%2F*%22%22%22%20%EC%84%9C%EB%B0%94%EC%9D%B4%EB%B2%8C%20%ED%94%8C%EB%9E%AB%ED%8F%BC%EC%97%90%20%EC%9C%84%ED%97%98%20%ED%85%8C%EC%9D%B4%EB%B8%94%20%EC%B6%94%EA%B0%80%20%EC%9E%91%EC%84%B1%EC%9E%90%3A%20jthi%20%EC%83%9D%EC%84%B1%20%EB%82%A0%EC%A7%9C%3A%202024-07-31%20%EC%83%9D%EC%84%B1%20JMP%20%EB%B2%84%EC%A0%84%3A%20JMP%20Pro%2018.0.1%20%EC%84%A4%EB%AA%85%3A%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying%3C%2FA%3E%20%EA%B8%B0%EC%A4%80%20-at-risk-tables-under-kaplan-meier%2Fmp%2F305898%2Fhighlight%2Ftrue%23M56162%20Todo%3A%20*%20%ED%99%95%EC%9D%B8%EC%9D%84%20%EB%88%84%EB%A5%B4%EA%B8%B0%20%EC%A0%84%EC%97%90%20%EC%82%AC%EC%9A%A9%EC%9E%90%EC%97%90%EA%B2%8C%20%EB%8B%A8%EA%B3%84%20%ED%91%9C%EC%8B%9C%20*%20%EB%AA%A8%EB%8B%AC%20%EC%B0%BD%20%EC%A0%9C%EA%B1%B0%20*%20%EC%B6%94%EA%B0%80%20%E2%80%8B%E2%80%8B%EA%B8%B0%EB%8A%A5%2F%EC%A0%81%EC%A0%88%ED%95%9C%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A1%9C%20%EC%A0%84%ED%99%98%20*%20%EC%A7%80%EC%B9%A8%2F%EC%A0%9C%EB%AA%A9%20%EC%B6%94%EA%B0%80%20UI%EC%97%90%20*%20%EC%9C%A0%ED%8B%B8%EB%A6%AC%ED%8B%B0%20%EB%AA%A8%EB%8B%AC%20%22%22%22%20%EC%B6%94%EA%B0%80*%2F%20%EC%97%AC%EA%B8%B0%EC%97%90%20%EA%B8%B0%EB%B3%B8%EA%B0%92%20%EC%9D%B4%EB%A6%84%20%EC%B6%94%EA%B0%80(1)%3B%20Ask_steps%20%3D%20function(%7B%7D%2C%20%7BDefault%20Local%7D%2C%20nw%20%3D%20New%20Window(%22%EC%9D%B4%EB%B2%A4%ED%8A%B8%20%EB%8B%A8%EA%B3%84%EA%B9%8C%EC%A7%80%EC%9D%98%20%EC%8B%9C%EA%B0%84%20%EC%B1%84%EC%9A%B0%EA%B8%B0%22%2C%20%26lt%3B%26lt%3B%20Type(%22%EB%AA%A8%EB%8B%AC%20%EB%8C%80%ED%99%94%20%EC%83%81%EC%9E%90%22)%2C%20%26lt%3B%26lt%3B%20%EB%B0%98%ED%99%98%20%EA%B2%B0%EA%B3%BC%2C%20H%20%EB%AA%A9%EB%A1%9D%20%EC%83%81%EC%9E%90(%20%ED%8C%A8%EB%84%90%20%EC%83%81%EC%9E%90(%22%EC%B1%84%EC%9A%B0%EA%B8%B0%20in%20steps%22%2C%20Lineup%20Box(N%20Col(2)%2C%20Text%20Box(%22%EC%B5%9C%EC%86%8C%20%EC%8B%9C%EA%B0%84%22)%2C%20neb_min%20%3D%20%EC%88%AB%EC%9E%90%20%ED%8E%B8%EC%A7%91%20%EC%83%81%EC%9E%90(.)%2C%20Text%20Box(%22%EC%B5%9C%EB%8C%80%20%EC%8B%9C%EA%B0%84%22)%2C%20neb_max%20%3D%20%EC%88%AB%EC%9E%90%20%ED%8E%B8%EC%A7%91%20%EC%83%81%EC%9E%90(.)%2C%20Text%20Box(%22%EB%8B%A8%EA%B3%84%20%EC%8B%9C%EA%B0%84%22)%2C%20neb_step%20%3D%20%EC%88%AB%EC%9E%90%20%ED%8E%B8%EC%A7%91%20%EC%83%81%EC%9E%90(.)%2C%20Text%20Box(%22%EB%A7%88%EC%A7%80%EB%A7%89%20%EB%B3%B4%EA%B0%84%22)%2C%20cb_interpolate%20%3D%20Check%20Box(%7B%22%22%7D%2C%20%26lt%3B%26lt%3B%20Set%20All(1))%20)%20)%2C%20Spacer%20Box(%20Size(20%2C%200))%2C%20Panel%20Box(%22%EC%9E%91%EC%97%85%22%2C%20Button%20Box(%22%ED%99%95%EC%9D%B8%22)%2C%20Button%20Box(%22%EC%B7%A8%EC%86%8C%22)%20)%20)%20%2C%20%26lt%3B%26lt%3B%20%EC%B0%BD%20%EC%95%84%EC%9D%B4%EC%BD%98%20%EC%84%A4%EC%A0%95(%22%EC%83%9D%EC%A1%B4%22)%20)%20If(nw%5B%22%20Button%22%5D%20!%3D%201%2C%20Throw(%22%EC%B7%A8%EC%86%8C%EB%90%A8%22)%3B%20)%3B%20min_t%20%3D%20nw%5B%22neb_min%22%5D%3B%20max_t%20%3D%20nw%5B%22neb_max%22%5D%3B%20step_t%20%3D%20nw%5B%22neb_step%22%5D%3B%20If(Any(Is%20Missing(%20min_t)%2C%20Is%20Missing(max_t)%2C%20Is%20Missing(step_t))%2C%20Throw(%22%EC%9E%85%EB%A0%A5%EB%90%98%EC%A7%80%20%EC%95%8A%EC%9D%80%20%EB%8B%A8%EA%B3%84%22)%20interpolate_last%20%3D%20N%20Items(nw%5B%22cb_interpolate%22%5D)%20return(Eval%20List(%7Bmin_t%2C%20max_t)%20%2C%20step_t%2C%20interpolate_last%7D))%20)%3B%20add_risk_table%20%3D%20function(%7Bplatform_ref%2C%20min_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D%2C%20%7BDefault%20Local%7D%2C%20rep%20%3D%20Report(platform_ref)%3B%20dt%20%3D%20platform_ref%20%26lt%3B%26lt%3B%20%EB%8D%B0%EC%9D%B4%ED%84%B0%20%ED%85%8C%EC%9D%B4%EB%B8%94%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%3B%20ycol%20%3D%20((rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FTextBox%20%5Btext()%3D'%EC%9D%B4%EB%B2%A4%ED%8A%B8%EA%B9%8C%EC%A7%80%EC%9D%98%20%EC%8B%9C%EA%B0%84%3A%20'%5D%22))%5B1%5D%20%26lt%3B%26lt%3B%20sib)%20%26lt%3B%26lt%3B%20%ED%85%8D%EC%8A%A4%ED%8A%B8%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%3B%20grouping_col%20%3D%20((rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FTextBox%5Btext()%3D'%EA%B7%B8%EB%A3%B9%ED%99%94%20%EA%B8%B0%EC%A4%80%20'%5D%20%22))%5B1%5D%20%26lt%3B%26lt%3B%20sib)%20%26lt%3B%26lt%3B%20%ED%85%8D%EC%8A%A4%ED%8A%B8%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%3B%20%EC%9A%94%EC%95%BD(dt%2C%20groups%20%3D%20by(Eval(grouping_col)))%3B%20steps%20%3D%20min_t%3A%3Amax_t%3A%3Astep_t%3B%20vals%20%3D%20steps%3B%20For%20Each(%7Bgroup%7D%20%2C%20groups%2C%20m_tb%20%3D%20rep%5BOutlineBox(group)%2C%20Table%20Box(1)%5D%20%26lt%3B%26lt%3B%20%ED%96%89%EB%A0%AC%EB%A1%9C%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%3B%20times%20%3D%20m_tb%5B0%2C%201%5D%20atrisk%20%3D%20m_tb%5B0%2C%20N%20Cols(m_tb)%5D%3B%20steps%2C%20times%2C%20atrisk)%3B%20%2F%2F%20%EC%9D%B4%20%EA%B2%BD%EC%9A%B0%20%EB%A7%88%EC%A7%80%EB%A7%89%20%ED%95%AD%EB%AA%A9%EC%9D%80%20%EA%B0%80%EC%A0%95%EB%90%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4.%20If(interpolate_last%2C%20If(times%5BN%20Rows(times)%2C%201%5D%20%26lt%3B%20max_t%20%26amp%3B%20Is%20Missing(cur_steps%5BN%20Cols(cur_steps)%5D)%2C%20cur_steps%20%5BN%20Cols(cur_steps)%5D%20%3D%20atrisk%5BN%20Rows(times)%2C%201%5D%3B%20)%3B%20vals%20%3D%20vals%20%7C%2F%20cur_steps%3B%20pb%20%3D%20Panel%20Box(%20String%20Col%20Box%20(Eval%20Insert(%22%EC%9C%84%ED%97%98%20%EC%97%86%EC%9D%8C(%5Eycol%5E)%22)%2C%20%EA%B7%B8%EB%A3%B9)%2C%20))%3B%20For(i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Cols(vals)%2C%20i%2B%2B%2C%20cur_vals%20%3D%20vals%5B0%2C%20i%5D%3B%20title%20%3D%20Char(Remove%20From(cur_vals%2C%201)%5B1%5D)%3B%20tb_results%20%26lt%3B%26lt%3B%20Append(Number%20Col%20Box(title%2C%20cur_vals))%3B%20)%3B%20rep%5B%EB%AA%A9%EB%A1%9D%20%EC%83%81%EC%9E%90(2)%5D%20%26lt%3B%26lt%3B%20Append(pb)%3B%20rep%5B%EB%AA%A9%EB%A1%9D%20%EC%83%81%EC%9E%90(2)%5D%20%26lt%3B%26lt%3B%20Append(Spacer%20Box(Size(0%2C%2010)))%3B%20)%3B%20cur_rep%20%3D%20%ED%98%84%EC%9E%AC%20%EB%B3%B4%EA%B3%A0%EC%84%9C()%3B%20If(Is%20%EB%B9%84%EC%96%B4%20%EC%9E%88%EC%9D%8C(cur_rep)%2C%20Throw(%22%EC%97%B4%EB%A6%B0%20%EB%B3%B4%EA%B3%A0%EC%84%9C%EA%B0%80%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4.%22)%3B%20)%3B%20ob_ref%20%E2%80%8B%E2%80%8B%3D%20cur_rep%20%26lt%3B%26lt%3B%20XPath(%22%2F%2FOutlineBox%5B%40helpKey%3D'Surv'%5D%22)%3B%20If(N%20Items(ob_ref)%20%3D%3D%200%2C%20Throw(%22Surv%20%ED%94%8C%EB%9E%AB%ED%8F%BC%EC%9D%84%20%EC%B0%BE%EC%9D%84%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4.%22)%3B%20)%3B%20Try(%20%7Bmin_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D%20%3D%20Ask_steps()%3B%20platform_ref%20%3D%20ob_ref%5B1%5D%20%26lt%3B%26lt%3B%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%20%EA%B0%80%EB%8A%A5%20%EA%B0%9D%EC%B2%B4%20%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0%3B%20add_risk_table(platform_ref%2C%20min_t%2C%20max_t%2C%20step_t%2C%20interpolate_last)%3B%20%2C%20Throw(%22%EA%B8%B0%ED%83%80%20%EB%AC%B8%EC%A0%9C%3A%20%22%20%7C%20%7C%20char(%EC%98%88%EC%99%B8_msg))%3B%20%EC%93%B0%EB%8B%A4()%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FNOSCRIPT%3E%3C%2FDIV%3E%3C%2FDIV%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
doraemengs
Level III

Risk Table of KM plot on JMP?

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

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Risk Table of KM plot on JMP?

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));
);

Edit: small fixes

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Risk Table of KM plot on JMP?

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));
);

Edit: small fixes

-Jarmo
doraemengs
Level III

Re: Risk Table of KM plot on JMP?

Hi Jarmo, Thank you for your help. It worked!

 

Best, Theerachai

jthi
Super User

Re: Risk Table of KM plot on JMP?

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

jthi_1-1722445639973.png

then you can run the script and it will ask for few things

jthi_0-1722445470437.png

Fill in those and press OK

jthi_2-1722445724506.png

It will then add the table to your existing report

jthi_3-1722445739773.png

 

Script below (and also attached). Use at your own risk, the calculations have not been checked

 

View more...
/*""" 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", << Type("Modal Dialog"), << 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({""}, << Set All(1))
				)
			),
			Spacer Box(Size(20, 0)),
			Panel Box("Actions",
				Button Box("OK"),
				Button Box("Cancel")
			)
		)
		, << 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 << Get Data Table;
	
	ycol = ((rep << XPath("//TextBox[text()='Time to event: ']"))[1] << sib) << get text;
	grouping_col = ((rep << XPath("//TextBox[text()='Grouped by ']"))[1] << sib) << 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)] << 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] < max_t & 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 <= N Cols(vals), i++,
		cur_vals = vals[0, i];
		
		title = Char(Remove From(cur_vals, 1)[1]);
		
		tb_results << Append(Number Col Box(title, cur_vals));
	);

	rep[List Box(2)] << Append(pb);
	rep[List Box(2)] << Append(Spacer Box(Size(0, 10)));
);



cur_rep = Current Report();
If(Is Empty(cur_rep),
	Throw("No reports open");
);

ob_ref = cur_rep << 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] << get scriptable object;

	add_risk_table(platform_ref, min_t, max_t, step_t, interpolate_last);
,
	Throw("Other issues: " || char(exception_msg));
);


Write();

 

 

-Jarmo