cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-777716%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EJMP%20%E3%81%AE%20KM%20%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%AE%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%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%E3%81%AE%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%81%AE%E8%A1%A8%E7%A4%BA%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%E3%81%AB%E3%82%88%E3%82%8B%E3%81%A8%E3%80%81KM%20%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%AE%E4%B8%8B%E3%81%AB%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%82%92%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%82%92%E6%95%99%E3%81%88%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%E3%80%82%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%AE%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AB%E5%BE%93%E3%81%8A%E3%81%86%E3%81%A8%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%81%8C%E3%80%81%E8%A7%A3%E6%B1%BA%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%9B%E3%82%93%E3%81%A7%E3%81%97%E3%81%9F%E3%80%82%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%E5%87%BA%E5%8A%9B%E3%81%AF%E6%B7%BB%E4%BB%98%E7%94%BB%E5%83%8F%E3%81%AE%E9%80%9A%E3%82%8A%E3%81%A7%E3%81%99%E3%80%82%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E4%BF%AE%E6%AD%A3%E3%81%97%E3%81%A6%E3%81%84%E3%81%9F%E3%81%A0%E3%81%91%E3%81%BE%E3%81%99%E3%81%8B%3F%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%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%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AE%E6%8E%A2%E7%B4%A2%E3%81%A8%E8%A6%96%E8%A6%9A%E5%8C%96%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%20%E3%81%AE%20KM%20%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%AE%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%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%E3%82%B3%E3%83%BC%E3%83%89%E3%82%92%E3%82%82%E3%81%86%E5%B0%91%E3%81%97%E3%83%91%E3%83%A9%E3%83%A1%E3%83%BC%E3%82%BF%E5%8C%96%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%E3%81%8C%E3%80%81minT%E3%80%81maxT%E3%80%81stepT%E3%80%81ycol%E3%80%81%E3%82%B0%E3%83%AB%E3%83%BC%E3%83%97%E5%8C%96%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%A6%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%80%81%E7%9B%AE%E7%9A%84%E3%81%AE%E5%8B%95%E4%BD%9C%E3%81%8C%E5%AE%9F%E7%8F%BE%E3%81%95%E3%82%8C%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F%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%E7%B7%A8%E9%9B%86%3A%20%E5%B0%8F%E3%81%95%E3%81%AA%E4%BF%AE%E6%AD%A3%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%20%E3%81%AE%20KM%20%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%AE%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%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%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E3%80%81Jarmo%E3%81%95%E3%82%93%E3%80%82%E3%81%94%E5%8D%94%E5%8A%9B%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%81%94%E3%81%96%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%E3%81%86%E3%81%BE%E3%81%8F%E3%81%84%E3%81%8D%E3%81%BE%E3%81%97%E3%81%9F!%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%E5%AE%9C%E3%81%97%E3%81%8F%E3%81%8A%E9%A1%98%E3%81%84%E8%87%B4%E3%81%97%E3%81%BE%E3%81%99%E3%80%81%E3%83%86%E3%82%A3%E3%83%BC%E3%83%A9%E3%83%81%E3%83%A3%E3%82%A4%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%20%E3%81%AE%20KM%20%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%81%AE%E3%83%AA%E3%82%B9%E3%82%AF%20%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%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%E7%94%9F%E5%AD%98%E8%80%85%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%81%A7%E5%9F%BA%E6%9C%AC%E7%9A%84%E3%81%AB%E4%BD%BF%E7%94%A8%E3%81%A7%E3%81%8D%E3%82%8B%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%82%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%E3%81%BB%E3%81%A8%E3%82%93%E3%81%A9%E3%81%AE%E5%A0%B4%E5%90%88%E3%81%AB%E6%A9%9F%E8%83%BD%E3%81%99%E3%82%8B%E3%81%8B%E3%82%82%E3%81%97%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93%E3%81%8C%E3%80%81%E3%81%93%E3%81%AE%20JMP%20%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%82%84%E5%88%86%E6%9E%90%E3%81%AB%E3%81%82%E3%81%BE%E3%82%8A%E8%A9%B3%E3%81%97%E3%81%8F%E3%81%AA%E3%81%84%E3%81%AE%E3%81%A7%E3%80%81%E6%A9%9F%E8%83%BD%E3%81%99%E3%82%8B%E3%81%8B%E3%81%A9%E3%81%86%E3%81%8B%E3%81%AF%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%E3%81%BE%E3%81%9F%E3%80%81%E8%A8%88%E7%AE%97%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F%E3%81%9F%E3%82%81%E3%80%81%E6%AD%A3%E7%A2%BA%E3%81%A7%E3%81%AF%E3%81%AA%E3%81%84%E5%8F%AF%E8%83%BD%E6%80%A7%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%E3%81%BE%E3%81%9A%E3%80%81%E7%94%9F%E5%AD%98%E8%80%85%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%82%92%E9%96%8B%E3%81%84%E3%81%A6%E3%81%8A%E3%81%8F%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%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%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E3%81%A8%E3%80%81%E3%81%84%E3%81%8F%E3%81%A4%E3%81%8B%E3%81%AE%E3%81%93%E3%81%A8%E3%82%92%E5%B0%8B%E3%81%AD%E3%82%89%E3%82%8C%E3%81%BE%E3%81%99%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%E3%81%9D%E3%82%8C%E3%82%89%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%97%E3%81%A6OK%E3%82%92%E6%8A%BC%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%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%E6%97%A2%E5%AD%98%E3%81%AE%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%81%AB%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%81%8C%E8%BF%BD%E5%8A%A0%E3%81%95%E3%82%8C%E3%81%BE%E3%81%99%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%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AF%E4%BB%A5%E4%B8%8B%EF%BC%88%E6%B7%BB%E4%BB%98%E3%82%82%EF%BC%89%E3%81%A7%E3%81%99%E3%80%82%3CSTRONG%3E%E8%A8%88%E7%AE%97%E3%81%AF%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%81%AA%E3%81%84%E3%81%9F%E3%82%81%E3%80%81%E8%87%AA%E5%B7%B1%E8%B2%AC%E4%BB%BB%E3%81%A7%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%E3%80%82%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%E3%82%82%E3%81%A3%E3%81%A8%E8%A6%8B%E3%82%8B...%3C%2FA%3E%3CNOSCRIPT%3E%EF%BC%88%E3%83%8F%E3%82%A4%E3%83%A9%E3%82%A4%E3%83%88%E3%81%97%E3%81%A6%E8%AA%AD%E3%82%93%E3%81%A7%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%EF%BC%89%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%E7%94%9F%E5%AD%98%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%AB%E3%83%AA%E3%82%B9%E3%82%AF%E8%A1%A8%E3%82%92%E8%BF%BD%E5%8A%A0%20%E4%BD%9C%E6%88%90%E8%80%85%3A%20jthi%20%E4%BD%9C%E6%88%90%E6%97%A5%3A%202024-07-31%20%E4%BD%9C%E6%88%90%20JMP%20%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%3A%20JMP%20Pro%2018.0.1%20%E8%AA%AC%E6%98%8E%3A%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying-at-risk-tables-under-kaplan-meier%2Fmp%2F305898%2Fhighlight%2Ftrue%23M56162%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FDisplaying-at-risk-tables-under-kaplan-meier%2Fmp%2F305898%2Fhighlight%2Ftrue%23M56162%3C%2FA%3E%20%E3%81%AB%E5%9F%BA%E3%81%A5%E3%81%8F%20%E3%82%84%E3%82%8B%E3%81%93%E3%81%A8%3A%20*%20%5BOK%5D%20%E3%82%92%E6%8A%BC%E3%81%99%E5%89%8D%E3%81%AB%E6%89%8B%E9%A0%86%E3%82%92%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%81%AB%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%20*%20%E3%83%A2%E3%83%BC%E3%83%80%E3%83%AB%20%E3%82%A6%E3%82%A3%E3%83%B3%E3%83%89%E3%82%A6%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B%20*%20%E3%82%A2%E3%83%89%E3%82%A4%E3%83%B3%20%2F%20%E9%81%A9%E5%88%87%E3%81%AA%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B%20*%20UI%20%E3%81%AB%E6%89%8B%E9%A0%86%20%2F%20%E3%82%BF%E3%82%A4%E3%83%88%E3%83%AB%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B%20*%20%E3%83%A6%E3%83%BC%E3%83%86%E3%82%A3%E3%83%AA%E3%83%86%E3%82%A3%20%E3%83%A2%E3%83%BC%E3%83%80%E3%83%AB%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B%20%22%22%22*%2F%20%E5%90%8D%E5%89%8D%E3%81%AE%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AF%20Here(1)%3B%20ask_steps%20%3D%20function(%7B%7D%2C%20%7BDefault%20Local%7D%2C%20nw%20%3D%20New%20Window(%22%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E3%81%AE%E6%99%82%E9%96%93%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%22%2C%20%26lt%3B%26lt%3B%20Type(%22Modal%20Dialog%22)%2C%20%26lt%3B%26lt%3B%20Return%20Result%2C%20H%20List%20Box(%20Panel%20Box(%22%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%22%2C%20Lineup%20Box(N%20Col(2)%2C%20Text%20Box(%22Min%20Time%22)%2C%20neb_min%20%3D%20Number%20Edit%20Box(.)%2C%20Text%20Box(%22Max%20Time%22)%2C%20neb_max%20%3D%20Number%20Edit%20Box(.)%2C%20Text%20Box(%22Step%20Time%22)%2C%20neb_step%20%3D%20Number%20Edit%20Box(.)%2C%20Text%20Box(%22Interpolate%20last%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(Size(20%2C%200))%2C%20Panel%20Box(%22Actions%22%2C%20Button%20Box(%22OK%22)%2C%20Button%20Box(%22Cancel%22)%20)%20)%20%2C%20%26lt%3B%26lt%3B%20Set%20Window%20Icon(%22Survival%22)%20)%3B%20If(nw%5B%22Button%22%5D%20!%3D%201%2C%20Throw(%22%E3%82%AD%E3%83%A3%E3%83%B3%E3%82%BB%E3%83%AB%E3%81%95%E3%82%8C%E3%81%BE%E3%81%97%E3%81%9F%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(min_t)%2C%20Is%20Missing(max_t)%2C%20Is%20Missing(step_t))%2C%20Throw(%22%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E3%81%8C%E5%85%A5%E5%8A%9B%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93%22)%3B%20)%3B%20interpolate_last%20%3D%20N%20Items(nw%5B%22cb_interpolate%22%5D)%3B%20return(Eval%20List(%7Bmin_t%2C%20max_t%2C%20step_t%2C%20interpolate_last%7D))%3B%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%20Get%20Data%20Table%3B%20ycol%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%20grouping_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%20Summarize(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%2C%20groups%2C%20m_tb%20%3D%20rep%5BOutlineBox(group)%2C%20Table%20Box(1)%5D%20%26lt%3B%26lt%3B%20get%20as%20matrix%3B%20times%20%3D%20m_tb%5B0%2C%201%5D%3B%20atrisk%20%3D%20m_tb%5B0%2C%20N%20Cols(m_tb)%5D%3B%20cur_steps%20%3D%20Step(steps%2C%20times%2C%20atrisk)%3B%20%2F%2F%20%E3%81%93%E3%81%AE%E5%A0%B4%E5%90%88%E3%80%81%E6%9C%80%E5%BE%8C%E3%81%AE%201%20%E3%81%A4%E3%81%AF%E6%83%B3%E5%AE%9A%E3%81%95%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93%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%5BN%20Cols(cur_steps)%5D%20%3D%20atrisk%5BN%20Rows(times)%2C%201%5D%3B%20)%3B%20)%3B%20vals%20%3D%20vals%20%7C%2F%20cur_steps%3B%20)%3B%20pb%20%3D%20Panel%20Box(%22Risk%20Table%22%2C%20tb_results%20%3D%20Table%20Box(%20String%20Col%20Box(Eval%20Insert(%22No%20at%20Risk%20(%5Eycol%5E)%22)%2C%20groups)%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%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20Append(pb)%3B%20rep%5BList%20Box(2)%5D%20%26lt%3B%26lt%3B%20Append(Spacer%20Box(Size(0%2C%2010)))%3B%20)%3B%20cur_rep%20%3D%20Current%20Report()%3B%20If(Is%20Empty(cur_rep)%2C%20Throw(%22%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%81%8C%E9%96%8B%E3%81%84%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93%22)%3B%20)%3B%20ob_ref%20%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%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%81%8C%E8%A6%8B%E3%81%A4%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%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%20get%20scriptable%20object%3B%20add_risk_table(platform_ref%2C%20min_t%2C%20max_t%2C%20step_t%2C%20interpolate_last)%3B%20%2C%20Throw(%22%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%AE%E5%95%8F%E9%A1%8C%3A%20%22%20%7C%7C%20char(exception_msg))%3B%20)%3B%20Write()%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